• 0 Votes
    3 Posts
    343 Views
    G
    Indeed we have the "socket.accept ()" method in the first LoPy, but the problem was in the pointing address to the other LoPy which was wrong. It's already solved, thank you!
  • LoPy4 BLE server

    LoPy lopy4 ble gatt lopy ble lopy ble service ble receive dat
    4
    0 Votes
    4 Posts
    484 Views
    J
    @xsklero There's an example of a BLE server here: https://docs.pycom.io/firmwareapi/pycom/network/bluetooth/gattscharacteristic.html Whatever you try, if you have an issue, you need to be more specific. Tell us what code you are using and the exact issue you are facing.
  • 0 Votes
    1 Posts
    294 Views
    No one has replied
  • Pymakr plug-in not working.

    LoPy lopy4
    2
    0 Votes
    2 Posts
    279 Views
    catalinC
    Hi @abhishek2101, do you still have a particular error? Maybe it's the node.js version, or some issue from Atom/VCS. I confirm the latest Pymakr works ok: Atom 1.34.0 -> pymakr 1.4.11 VSC 1.31.1 -> pymakr 1.0.7
  • Wake on any RX

    LoPy lopy4 sleep power saving
    4
    0 Votes
    4 Posts
    628 Views
    J
    @hanssanitizer Leaving the LoRa radio in RX mode means the LoRa chip will be drawing a bit over 10 mA at all times. What are your constraints in terms of battery size and battery lifetime? A relatively large 2500 mAh will be emptied in 10 days in this scheme, not even counting what is drawn when the LoPy is awake, so probably less than a week overall, depending on how often it wakes up, for how long, and what it does. If that's something that is acceptable for you, then one could probably explore modifying the firmware to handle that, though my guess the complexity will arise from having to bypass all the LoRa chip initialisation on startup. Note that if that kind of power budget is acceptable, maybe just using the light sleep modes may be OK and probably much easier. For reference, the original LoPy uses the SX1272 while the LoPy4 uses the SX1276. I believe the FiPy uses the SX1276 as well.
  • adafruit circuitpython

    LoPy lopy4
    2
    0 Votes
    2 Posts
    326 Views
    robert-hhR
    @abhishek2101 two aspects: are we allowed to? The answer is yes. Adafruit uses the MIT licensing, which gives you a lot of freedom. will the libraries work? Not out-of-the box for most of them. You typically have to adapt access to peripheral devices like I2C, SPI etc. Adafruit uses a different hardware abstraction method. But the required changes are typically small, and the adafruit libraries are often well designed.
  • lopy4 RTC

    LoPy lopy4
    10
    0 Votes
    10 Posts
    1k Views
    P
    @rcolistete I was incorrect in my previous posting. When using a Pysense/Pytrack and the deepsleep functions available in there respective API's. the main ESP32 processor is powered off and thus the RTC data is lost. Example: https://docs.pycom.io/pytrackpysense/apireference/sleep.html #from pytrack import Pytrack from pysense import Pysense from LIS2HH12 import LIS2HH12 import time #py = Pytrack() py = Pysense() # display the reset reason code and the sleep remaining in seconds # possible values of wakeup reason are: # WAKE_REASON_ACCELEROMETER = 1 # WAKE_REASON_PUSH_BUTTON = 2 # WAKE_REASON_TIMER = 4 # WAKE_REASON_INT_PIN = 8 print("Wakeup reason: " + str(py.get_wake_reason())) print("Approximate sleep remaining: " + str(py.get_sleep_remaining()) + " sec") time.sleep(0.5) # go to sleep for 5 minutes maximum if no accelerometer interrupt happens this will also lose the RTC data. py.setup_sleep(300) py.go_to_sleep() When using the API available in the machine library. The RTC data is retained during deepsleep. import machine machine.deepsleep(5000) # sleep for 5 seconds. and retain the RTC data. this does not power off the esp32 but does put it in a very low power state
  • Data transfer via Bluetooth?

    WiPy 2&3 wipy3.0 lopy4 ble bluetooth fipy
    1
    1 Votes
    1 Posts
    417 Views
    No one has replied
  • Windows 10 "Please Connect Your Device"

    LoPy lopy4 window10 visual studio
    3
    3
    0 Votes
    3 Posts
    371 Views
    A
    @paul-thornton No errors that I can see. Is there a log file? I am connecting to the windows machine using the same usb cord that works on the mac.
  • If setup as a LoRaWan Nano gateway...

    LoPy lopy4 gateway feather
    3
    0 Votes
    3 Posts
    354 Views
    C
    Fair enough, I did quite a bit of reading on TTN about Gateways, Nodes, Applications, etc... I think once I can muster up some more funds for an actual Gateway; I will convert this to a Node. This PyCom LoPy4 is really a learning experience for me. The idea of using MicroPython is all new to me. Cheers,
  • 0 Votes
    3 Posts
    861 Views
    J
    @paul-thornton Thanks, this worked! I figured out that the same addition 'region=LoRa.EU868' is needed at 4 locations in nanogateway.py: around line 169, 263, 355, and 378. I still have a problem with the downlink not getting to the node (without giving any error message). This may be a timing problem: Only in one instance, the TTN website indicated that the node confirmed receipt of the downlink. In all other cases, no such confirmation was received. Let me investigate that further first.
  • lopy4 hangs with "ERROR! Could not connect to Pybytes"

    LoPy lopy4
    3
    0 Votes
    3 Posts
    634 Views
    G
    @Paul-Thornton I have the same problem. Using the solution proposed by you does not fix the issue. I disabled also the firewall. Firmware: 1.18.2.r3 Pybytes: 0.9.10 Pybytes configuration read from /flash/pybytes_config.json WiFi connection established MQTT ERROR! Avialable Interfaces are down ERROR! Could not connect to Pybytes! This is error printed in the REPL console. @dnear1 If you want to connect to Pybytes and you did all the steps to register your board it is not necessary to connect to wi-fi in the boot.py The wi-fi network connection is handled by pybytes so basically the pybytes will not have the wlan interface.
  • <class 'OSError'> Avialable Interfaces are down

    LoPy lopy4 oserror lopy interfaces
    15
    0 Votes
    15 Posts
    2k Views
    M
    @johand After I've set IP for HTTP server wlan.ifconfig(id=1, config=('192.168.4.10', '255.255.255.0', '192.168.4.1', '192.168.4.1')) i've tried to read IP address of HTTP Server and that was the problem, it's keep returning me '0.0.0.0'. IP address was set properly to '192.168.4.10' but function returns '0.0.0.0'. print('Network config:', wlan.ifconfig()) Network config: ('0.0.0.0', '0.0.0.0', '0.0.0.0', '0.0.0.0') Thank you for your help. @pigamonte I've managed to do it with 1.18.2.
  • lopy4 deep sleep

    LoPy lopy4 power
    10
    0 Votes
    10 Posts
    1k Views
    robert-hhR
    @abhishek2101 Go to the profile of the person you want to chat with, and in the middel right there is a circle with some dots. If you open that, teh first topic is: start a chat.
  • lopy4 with gps

    LoPy lopy4
    5
    0 Votes
    5 Posts
    500 Views
    J
    @abhishek2101 most GPS modules have standard NMEA output, so I would be surprised if this one didn’t.
  • Porting adafruit TSL2591 micropython to Pycom library

    LoPy lopy4
    3
    0 Votes
    3 Posts
    570 Views
    D
    I made those changes and worked thru a few more issues. I get output the first time thru then it breaks. Still working through that but here's what I've got so far Serial output: [41, 64] [41, 64] [41, 64] [41, 64] [41, 64] Total light: 55.55328lux [41, 64] [41, 64] Infrared light: 141 [41, 64] [41, 64] Visible light: 9241007 [41, 64] [41, 64] Full spectrum (IR + visible) light: 9241149 [41, 64] [41, 64] Total light: 0.0lux [41, 64] [41, 64] Infrared light: 0 [41, 64] [41, 64] Visible light: 0 [41, 64] [41, 64] Full spectrum (IR + visible) light: 0 the zero outputs repeat the rest of the tries. tsl2591.py: # The MIT License (MIT) # # Copyright (c) 2017 Tony DiCola for Adafruit Industries # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """ `adafruit_tsl2591` ==================================================== CircuitPython module for the TSL2591 precision light sensor. See examples/simpletest.py for a demo of the usage. * Author(s): Tony DiCola Implementation Notes -------------------- **Hardware:** * Adafruit `TSL2591 High Dynamic Range Digital Light Sensor <https://www.adafruit.com/product/1980>`_ (Product ID: 1980) **Software and Dependencies:** * Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice """ from micropython import const #import adafruit_bus_device.i2c_device as i2c_device from machine import I2C,Pin #__version__ = "0.0.0-auto.0" #__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_TSL2591.git" #pylint: disable=bad-whitespace # Internal constants: _TSL2591_ADDR = const(0x29) _TSL2591_COMMAND_BIT = const(0xA0) _TSL2591_ENABLE_POWEROFF = const(0x00) _TSL2591_ENABLE_POWERON = const(0x01) _TSL2591_ENABLE_AEN = const(0x02) _TSL2591_ENABLE_AIEN = const(0x10) _TSL2591_ENABLE_NPIEN = const(0x80) _TSL2591_REGISTER_ENABLE = const(0x00) _TSL2591_REGISTER_CONTROL = const(0x01) _TSL2591_REGISTER_DEVICE_ID = const(0x12) _TSL2591_REGISTER_CHAN0_LOW = const(0x14) _TSL2591_REGISTER_CHAN1_LOW = const(0x16) _TSL2591_LUX_DF = 408.0 _TSL2591_LUX_COEFB = 1.64 _TSL2591_LUX_COEFC = 0.59 _TSL2591_LUX_COEFD = 0.86 _TSL2591_MAX_COUNT_100MS = const(36863) # 0x8FFF _TSL2591_MAX_COUNT = const(65535) # 0xFFFF # User-facing constants: GAIN_LOW = 0x00 # low gain (1x) """Low gain (1x)""" GAIN_MED = 0x10 # medium gain (25x) """Medium gain (25x)""" GAIN_HIGH = 0x20 # medium gain (428x) """High gain (428x)""" GAIN_MAX = 0x30 # max gain (9876x) """Max gain (9876x)""" INTEGRATIONTIME_100MS = 0x00 # 100 millis """100 millis""" INTEGRATIONTIME_200MS = 0x01 # 200 millis """200 millis""" INTEGRATIONTIME_300MS = 0x02 # 300 millis """300 millis""" INTEGRATIONTIME_400MS = 0x03 # 400 millis """400 millis""" INTEGRATIONTIME_500MS = 0x04 # 500 millis """500 millis""" INTEGRATIONTIME_600MS = 0x05 # 600 millis """600 millis""" #pylint: enable=bad-whitespace class TSL2591: """TSL2591 high precision light sensor. :param busio.I2C i2c: The I2C bus connected to the sensor :param int address: The I2C address of the sensor. If not specified the sensor default will be used. """ # Class-level buffer to reduce memory usage and allocations. # Note this is NOT thread-safe or re-entrant by design. _BUFFER = bytearray(2) def __init__(self, i2c, address=_TSL2591_ADDR): self._integration_time = 0 self._gain = 0 self.i2c=i2c#I2C(pins=("P9","P10")) self._i2c_address=address #self._device = i2c_device.I2CDevice(i2c, address) # Verify the chip ID. if self._read_u8(_TSL2591_REGISTER_DEVICE_ID) != 0x50: raise RuntimeError('Failed to find TSL2591, check wiring!') # Set default gain and integration times. self.gain = GAIN_MED self.integration_time = INTEGRATIONTIME_100MS # Put the device in a powered on state after initialization. self.enable() def _read_u8(self, address): # Read an 8-bit unsigned value from the specified 8-bit address. #with self._device as i2c: # Make sure to add command bit to read request. #self._BUFFER[0] = (_TSL2591_COMMAND_BIT | address) & 0xFF # self.i2c.writeto(self._BUFFER, end=1, stop=False) #self.i2c.writeto(_TSL2591_ADDR,self._BUFFER) #self.i2c.readinto(self._BUFFER, end=1) print(self.i2c.scan()) self.i2c.readfrom_mem_into(self._i2c_address,(_TSL2591_COMMAND_BIT|address) & 0xFF,self._BUFFER) return self._BUFFER[0] # Disable invalid name check since pylint isn't smart enough to know LE # is an abbreviation for little-endian. #pylint: disable=invalid-name def _read_u16LE(self, address): # Read a 16-bit little-endian unsigned value from the specified 8-bit # address. #with self._device as i2c: # Make sure to add command bit to read request. #self._BUFFER[0] = (_TSL2591_COMMAND_BIT | address) & 0xFF #self.i2c.write(self._BUFFER, end=1, stop=False) #self.i2c.readinto(self._BUFFER, end=2) print(self.i2c.scan()) self.i2c.readfrom_mem_into(self._i2c_address,(_TSL2591_COMMAND_BIT|address) & 0xFF,self._BUFFER) return (self._BUFFER[1] << 8) | self._BUFFER[0] #pylint: enable=invalid-name def _write_u8(self, address, val): # Write an 8-bit unsigned value to the specified 8-bit address. #with self._device as i2c: # Make sure to add command bit to write request. #self._BUFFER[0] = (_TSL2591_COMMAND_BIT | address) & 0xFF #self._BUFFER[1] = val & 0xFF #self.i2c.write(self._BUFFER, end=2) self.i2c.writeto_mem(self._i2c_address,(_TSL2591_COMMAND_BIT | address) & 0xFF,val & 0xFF) def enable(self): """Put the device in a fully powered enabled mode.""" self._write_u8(_TSL2591_REGISTER_ENABLE, _TSL2591_ENABLE_POWERON | \ _TSL2591_ENABLE_AEN | _TSL2591_ENABLE_AIEN | \ _TSL2591_ENABLE_NPIEN) def disable(self): """Disable the device and go into low power mode.""" self._write_u8(_TSL2591_REGISTER_ENABLE, _TSL2591_ENABLE_POWEROFF) @property def gain(self): """Get and set the gain of the sensor. Can be a value of: - ``GAIN_LOW`` (1x) - ``GAIN_MED`` (25x) - ``GAIN_HIGH`` (428x) - ``GAIN_MAX`` (9876x) """ control = self._read_u8(_TSL2591_REGISTER_CONTROL) return control & 0b00110000 @gain.setter def gain(self, val): assert val in (GAIN_LOW, GAIN_MED, GAIN_HIGH, GAIN_MAX) # Set appropriate gain value. control = self._read_u8(_TSL2591_REGISTER_CONTROL) control &= 0b11001111 control |= val self._write_u8(_TSL2591_REGISTER_CONTROL, control) # Keep track of gain for future lux calculations. self._gain = val @property def integration_time(self): """Get and set the integration time of the sensor. Can be a value of: - ``INTEGRATIONTIME_100MS`` (100 millis) - ``INTEGRATIONTIME_200MS`` (200 millis) - ``INTEGRATIONTIME_300MS`` (300 millis) - ``INTEGRATIONTIME_400MS`` (400 millis) - ``INTEGRATIONTIME_500MS`` (500 millis) - ``INTEGRATIONTIME_600MS`` (600 millis) """ control = self._read_u8(_TSL2591_REGISTER_CONTROL) return control & 0b00000111 @integration_time.setter def integration_time(self, val): assert 0 <= val <= 5 # Set control bits appropriately. control = self._read_u8(_TSL2591_REGISTER_CONTROL) control &= 0b11111000 control |= val self._write_u8(_TSL2591_REGISTER_CONTROL, control) # Keep track of integration time for future reading delay times. self._integration_time = val @property def raw_luminosity(self): """Read the raw luminosity from the sensor (both IR + visible and IR only channels) and return a 2-tuple of those values. The first value is IR + visible luminosity (channel 0) and the second is the IR only (channel 1). Both values are 16-bit unsigned numbers (0-65535). """ # Read both the luminosity channels. channel_0 = self._read_u16LE(_TSL2591_REGISTER_CHAN0_LOW) channel_1 = self._read_u16LE(_TSL2591_REGISTER_CHAN1_LOW) return (channel_0, channel_1) @property def full_spectrum(self): """Read the full spectrum (IR + visible) light and return its value as a 32-bit unsigned number. """ channel_0, channel_1 = self.raw_luminosity return (channel_1 << 16) | channel_0 @property def infrared(self): """Read the infrared light and return its value as a 16-bit unsigned number. """ _, channel_1 = self.raw_luminosity return channel_1 @property def visible(self): """Read the visible light and return its value as a 32-bit unsigned number. """ channel_0, channel_1 = self.raw_luminosity full = (channel_1 << 16) | channel_0 return full - channel_1 @property def lux(self): """Read the sensor and calculate a lux value from both its infrared and visible light channels. """ channel_0, channel_1 = self.raw_luminosity # Compute the atime in milliseconds atime = 100.0 * self._integration_time + 100.0 # Set the maximum sensor counts based on the integration time (atime) setting if self._integration_time == INTEGRATIONTIME_100MS: max_counts = _TSL2591_MAX_COUNT_100MS else: max_counts = _TSL2591_MAX_COUNT # Handle overflow. if channel_0 >= max_counts or channel_1 >= max_counts: raise RuntimeError('Overflow reading light channels!') # Calculate lux using same equation as Arduino library: # https://github.com/adafruit/Adafruit_TSL2591_Library/blob/master/Adafruit_TSL2591.cpp again = 1.0 if self._gain == GAIN_MED: again = 25.0 elif self._gain == GAIN_HIGH: again = 428.0 elif self._gain == GAIN_MAX: again = 9876.0 cpl = (atime * again) / _TSL2591_LUX_DF lux1 = (channel_0 - (_TSL2591_LUX_COEFB * channel_1)) / cpl lux2 = ((_TSL2591_LUX_COEFC * channel_0) - (_TSL2591_LUX_COEFD * channel_1)) / cpl return max(lux1, lux2) main.py: # Simple demo of the TSL2591 sensor. Will print the detected light value # every second. import time from machine import I2C, Pin #added for tsl2591 sensor #import board #import busio import tsl2591 #i2c = I2C(0, pins=("P9","P10")) # Initialize the I2C bus. i2c = I2C(0,pins=("P9","P10"))#board.SCL, board.SDA) #i2c=i2c i2c.init(I2C.MASTER, baudrate=9600) # Initialize the sensor. sensor = tsl2591.TSL2591(i2c) # You can optionally change the gain and integration time: #sensor.gain = adafruit_tsl2591.GAIN_LOW (1x gain) #sensor.gain = adafruit_tsl2591.GAIN_MED (25x gain, the default) #sensor.gain = adafruit_tsl2591.GAIN_HIGH (428x gain) #sensor.gain = adafruit_tsl2591.GAIN_MAX (9876x gain) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_100MS (100ms, default) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_200MS (200ms) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_300MS (300ms) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_400MS (400ms) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_500MS (500ms) #sensor.integration_time = adafruit_tsl2591.INTEGRATIONTIME_600MS (600ms) # Read the total lux, IR, and visible light levels and print it every second. while True: # Read and calculate the light level in lux. lux = sensor.lux print('Total light: {0}lux'.format(lux)) # You can also read the raw infrared and visible light levels. # These are unsigned, the higher the number the more light of that type. # There are no units like lux. # Infrared levels range from 0-65535 (16-bit) infrared = sensor.infrared print('Infrared light: {0}'.format(infrared)) # Visible-only levels range from 0-2147483647 (32-bit) visible = sensor.visible print('Visible light: {0}'.format(visible)) # Full spectrum (visible + IR) also range from 0-2147483647 (32-bit) full_spectrum = sensor.full_spectrum print('Full spectrum (IR + visible) light: {0}'.format(full_spectrum)) time.sleep(1.0)
  • Changing the Lopy4's Wi-Fi AP SSID name

    LoPy lopy4 wifi ssid setup
    2
    0 Votes
    2 Posts
    397 Views
    M
    wl.init(mode=WLAN.STA_AP, ssid="apssid", auth=(WLAN.WPA2,'12378'), channel=7, antenna=WLAN.INT_ANT) available_nets = wl.scan()
  • 0 Votes
    2 Posts
    366 Views
    P
    Ive pointed the correct people at this thread. one of them should be able to answer soon :)
  • Lopy4 - 3.3V out disable?

    LoPy lopy4 3.3v machine.deepsle
    8
    0 Votes
    8 Posts
    803 Views
    M
    @jcaron The ESP32 data sheet https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf says high level source current IOH is 20 or 40 mA, depending on domain. The voltage will probably be quite noisy as it comes from the digital supply of the ESP32. The HX711 is a 24 bit sigma delta front end for load cells. For optimal performance, I'd power this from a separate regulator, but try it... If you look at the data sheet https://www.mouser.com/ds/2/813/hx711_english-1022875.pdf you see it has an internal analog regulator. Running from a 3.3 V supply, I'd set the analog voltage to 3.0 V, which would at least reduce the noise. Also note that the IO driver of the ESP32 (or any digital device) has a much higher resistance than an external FET switch you'd typically use (there are no specs on this in the datasheet), introducing additional errors.
  • 0 Votes
    2 Posts
    385 Views
    F
    @Giorgio Did you find out how? I have the same problem here, using a gPy+Expansion Board V3.1. I can't find a way to put the board in deepsleep mode. It is currently using 14mA. I can only find documentation for Pysense/Pytrack/DSboard, etc.. but nothing for the Expansion Board!? :\ Where's the info I am missing? Fakstory