• Pytrack + GPy. Where to connect sensors?

    Expansion Board pytrack gpy sensors pins
    2
    0 Votes
    2 Posts
    341 Views
    S
    @fedonman Depends on the sensors really. What bus (i2C, SPI, etc) or other port you need. Other factors are the power supply required and any other such factors. My practice is to extend the bus/es from the sockets Expansion/Pytrack board to a protoboard, so I am able to connect more than one device, power supply, level shifters, pull up/down resistors, capacitors etc if required. Makes it easier to work on and follows on with making a custom PCB later on..
  • Pytrack + GPy. Where to connect sensors?

    GPy pytrack gpy sensors pinouts
    2
    0 Votes
    2 Posts
    381 Views
    P
    Ideally the external headers if the pins match your usecase.
  • 0 Votes
    13 Posts
    1k Views
    O
    @robert-hh I looked at that device but I'm trying to keep my system as simple as possible so I did not pursue that option. I does, however, look like a viable alternative in the event your s/w solution was inadequate for some reason. thanks.
  • 0 Votes
    2 Posts
    529 Views
    robert-hhR
    @nobo23 Accirdoig to the datasheet, you can operate that device from the 3.3V output of the WiPy. That matches the signal levels of the I2C interface. Since the module has built-in pull-up resistors (if you install the jumpers), you do not have to add additional ones.
  • Educational Grove shield for Pycom devices

    Discussion grove shield sensors
    2
    4 Votes
    2 Posts
    697 Views
    J
    @marcozennaro Great project, thank you for sharing
  • 0 Votes
    2 Posts
    644 Views
    L
    @matthew look at attenuation https://docs.pycom.io/chapter/firmwareapi/pycom/machine/ADC.html#adcchannel--pin-attnadcattn0db try ADC.ATTN_11DB
  • Need help

    LoPy lopy lora adc sensors
    6
    0 Votes
    6 Posts
    1k Views
    M
    @livius I'm actually using this code, because I'm looking to get the blink of the meter. [image: 1522831409-sans-titre.png] Know I need to find when the led is blinking, because he send everytime the value. I want to know how to check the difference between this value and the last one.
  • Blynk on LoPy

    LoPy blynk lopy sensors android app lora
    2
    2 Votes
    2 Posts
    1k Views
    E
    Hi @gruia-nichita I'm using LoPy with Blynk via WiFi, but am also interested in using it with LoRa, let me know if you find a solution (I haven't looked at LoRa+Blynk with enough detail yet...) I'm using BlynkLib : https://github.com/vshymanskyy/blynk-library-python
  • Documentation

    Comments & Feedback documentation lopy sensors
    8
    0 Votes
    8 Posts
    2k Views
    L
    @fred I have had a similar experience to this post from 6 months ago. What's changed since then? https://forum.pycom.io/topic/1452/first-steps-with-lopy-pysense-and-feedback Will i achieve anything by complaining, probably not and will not benefit this community . However when i purchase a product(s) that is released to joe public you do expect many of the bugs to be ironed out with a smoother onborading process. I'll be first to say i don't no everything and most definitely not an expert in python but hey that's why we look at products such pycom to develop and learn. So what have i done so far; I've updated the lopy firmware with the tool provided. Orientating the lopy was not straight forward and this goes for the pysens/pytrack. If i did not have an expansion board how do i update the firmware using a pysense? *I did the usual pycom hello world of LED lights. GREAT!! VS Code is working and syncing as it expected. *Next i connected to WiFi and used SSH to log in.GREAT!! I thought this was easy. *I explored sending events to AWS and Azure. After some tinkering a made it happen posting sample json data. GREAT!! Now lets connect the pysense and collect some real data! *I have struggled installing drivers and updating pysense firmware or should i say understating if it has completed correctly. [image: 1513372576892-5ab52586-b40c-45fa-a5a7-034c2f165dca-image.png] I can only assume i have at this point. I then had to roll back the Windows driver so i could communicate on COM4? *I go to github to download pysense libs and sample program. https://github.com/pycom/pycom-libraries/tree/master/pysense I have a couple of errors [image: 1513373609061-b787c40e-1066-4869-b4a2-61a3795ec5c6-image.png] [image: 1513373640677-5456002e-1cd7-4fa6-b0a8-edc0c01f15a6-image-resized.png] So i see pycoproc is required in the ERROR, so lets get that and it to my pycom lib [image: 1513374008265-c0d0b338-af98-4d7b-accf-1790ed1a6ac2-image-resized.png] But hold on team.... pycoproc is within its folder. It actually need to be in the root of lib right? GREAT!!! We are now running with pysense [image: 1513374297924-a78f889e-3c27-4462-a295-d534f005edb1-image.png] [image: 1513374341557-3bd6e987-6dd9-4737-88fd-83235172fcf3-image.png] Following the Pycom tutorials is there any reference to pycoproc? I'm all about discovering and going out to find the information - what a great way to learn. I feel it would benefit all levels knowledge if you had projects packaged up ready to go that we can use as a benchmark or fall back if something stops working we can then trouble shoot hardware easily. A library of short 3min videos would be a great for people getting started. i'm a member of the Dev xpress framework and there documentation is the best i have ever experienced. Check you there getting started videos. Simple but very effective. https://www.devexpress.com/Support/Start/ i'm with the community and agree this hardware is pretty cool but i want to get up and running in a couple of mins running sample code from there we can go and invent!! Thanks Lewis
  • Determining status of individual sensors.

    Discussion pysense sensors
    7
    0 Votes
    7 Posts
    1k Views
    A
    The simplest solutions are the best. I'll give that a go. Many thanks @seb.
  • Grove Sensors

    WiPy 2&3 grove sensors
    9
    0 Votes
    9 Posts
    2k Views
    F
    @robert-hh Thanks a lot...I will try soon
  • 0 Votes
    8 Posts
    2k Views
    L
    @kop524 said in temerature sensor for Wipy 2.0 w/ext. board: As near all pins can be redirected then choose is quite simple i only ommit for sensors pins used for SD card communication and sometimes inputonly look at https://docs.pycom.io/chapter/datasheets/ there are good descriptions about pins - you must choose self.
  • 0 Votes
    1 Posts
    1k Views
    No one has replied
  • ADXL 345 (from Adafruit)

    Discussion adxl345 accelerometer sensor adafruit sensors
    14
    0 Votes
    14 Posts
    4k Views
    D
    @Lokefar Can you post the final working code for this sensor with lopy 4?
  • NTC temperature sensor

    Moved LoPy sensors lopy adc temperature ntc
    26
    0 Votes
    26 Posts
    15k Views
    robert-hhR
    @jmarcelino: Yes, Ive read that. But you would still have to compensate for the non-zero range (at least in your circuit). So at the moment and with limited requirements for precision, using the lower attenuation variants 0 and 6db and simply adding an offset would be sufficient as compensation. If you need precise values, yes, then an external ADC is anyhow recommended. B.T.W. Is there still the option to use the ADC in 10 bit mode, like by an option res = xx in the channel set-up?
  • Time & Interrupts

    Moved MicroPython interrupt time sensors
    7
    0 Votes
    7 Posts
    4k Views
    robert-hhR
    @Emmanuel-Goudot Yes, that's the piece of code below, which works for my DHT22 on a Lopy. It is buried far below in a thread, where two people fight to get it running(https://forum.pycom.io/topic/1172/pure-python-library-for-reading-dht-sensor-on-pycom-boards). No clue what their problem is, since I consider it solved, even if not bullet proof. import time from machine import enable_irq, disable_irq, Pin class DTHResult: 'DHT sensor result returned by DHT.read() method' ERR_NO_ERROR = 0 ERR_MISSING_DATA = 1 ERR_CRC = 2 error_code = ERR_NO_ERROR temperature = -1 humidity = -1 def __init__(self, error_code, temperature, humidity): self.error_code = error_code self.temperature = temperature self.humidity = humidity def is_valid(self): return self.error_code == DTHResult.ERR_NO_ERROR class DTH: 'DHT sensor (dht11, dht21,dht22) reader class for Pycom' __pin = Pin('P3', mode=Pin.OPEN_DRAIN) __dhttype = 0 def __init__(self, pin, sensor=0): self.__pin = pin self.__pin(1) self.__dhttype = sensor def read(self): time.sleep(1) # send initial high #self.__send_and_sleep(1, 25000) # pull down to low #self.__send_and_sleep(0, 40000) # collect data into an array data = self.__collect_input() # parse lengths of all data pull up periods pull_up_lengths = self.__parse_data_pull_up_lengths(data) # if bit count mismatch, return error (4 byte data + 1 byte checksum) print(pull_up_lengths) if len(pull_up_lengths) != 40: return DTHResult(DTHResult.ERR_MISSING_DATA, 0, 0) # calculate bits from lengths of the pull up periods bits = self.__calculate_bits(pull_up_lengths) # we have the bits, calculate bytes the_bytes = self.__bits_to_bytes(bits) print(the_bytes) # calculate checksum and check checksum = self.__calculate_checksum(the_bytes) if the_bytes[4] != checksum: return DTHResult(DTHResult.ERR_CRC, 0, 0) # ok, we have valid data, return it [int_rh, dec_rh, int_t, dec_t, csum] = the_bytes if self.__dhttype==0: #dht11 rh = int_rh #dht11 20% ~ 90% t = int_t #dht11 0..50°C else: #dht21,dht22 rh = ((int_rh * 256) + dec_rh)/10 t = (((int_t & 0x7F) * 256) + dec_t)/10 if (int_t & 0x80) > 0: t *= -1 return DTHResult(DTHResult.ERR_NO_ERROR, t, rh) def __send_and_sleep(self, output, mysleep): self.__pin(output) time.sleep_us(mysleep) def __collect_input(self): # collect the data while unchanged found unchanged_count = 0 # this is used to determine where is the end of the data max_unchanged_count = 100 last = -1 data = [] m = [1]*500 # needs long sample size to grab all the bits from the DHT self.__pin(0) time.sleep_us(20000) self.__pin(1) irqf = disable_irq() for i in range(len(m)): m[i] = self.__pin() ## sample input and store value enable_irq(irqf) for i in range(len(m)): current = m[i] data.append(current) if last != current: unchanged_count = 0 last = current else: unchanged_count += 1 if unchanged_count > max_unchanged_count: break #print(data) return data def __parse_data_pull_up_lengths(self, data): STATE_INIT_PULL_DOWN = 1 STATE_INIT_PULL_UP = 2 STATE_DATA_FIRST_PULL_DOWN = 3 STATE_DATA_PULL_UP = 4 STATE_DATA_PULL_DOWN = 5 state = STATE_INIT_PULL_UP lengths = [] # will contain the lengths of data pull up periods current_length = 0 # will contain the length of the previous period for i in range(len(data)): current = data[i] current_length += 1 if state == STATE_INIT_PULL_DOWN: if current == 0: # ok, we got the initial pull down state = STATE_INIT_PULL_UP continue else: continue if state == STATE_INIT_PULL_UP: if current == 1: # ok, we got the initial pull up state = STATE_DATA_FIRST_PULL_DOWN continue else: continue if state == STATE_DATA_FIRST_PULL_DOWN: if current == 0: # we have the initial pull down, the next will be the data pull up state = STATE_DATA_PULL_UP continue else: continue if state == STATE_DATA_PULL_UP: if current == 1: # data pulled up, the length of this pull up will determine whether it is 0 or 1 current_length = 0 state = STATE_DATA_PULL_DOWN continue else: continue if state == STATE_DATA_PULL_DOWN: if current == 0: # pulled down, we store the length of the previous pull up period lengths.append(current_length) state = STATE_DATA_PULL_UP continue else: continue return lengths def __calculate_bits(self, pull_up_lengths): # find shortest and longest period shortest_pull_up = 1000 longest_pull_up = 0 for i in range(0, len(pull_up_lengths)): length = pull_up_lengths[i] if length < shortest_pull_up: shortest_pull_up = length if length > longest_pull_up: longest_pull_up = length # use the halfway to determine whether the period it is long or short halfway = shortest_pull_up + (longest_pull_up - shortest_pull_up) / 2 bits = [] for i in range(0, len(pull_up_lengths)): bit = False if pull_up_lengths[i] > halfway: bit = True bits.append(bit) return bits def __bits_to_bytes(self, bits): the_bytes = [] byte = 0 for i in range(0, len(bits)): byte = byte << 1 if (bits[i]): byte = byte | 1 else: byte = byte | 0 if ((i + 1) % 8 == 0): the_bytes.append(byte) byte = 0 #print(the_bytes) return the_bytes def __calculate_checksum(self, the_bytes): return the_bytes[0] + the_bytes[1] + the_bytes[2] + the_bytes[3] & 255