• Benvenuti su RaspberryItaly!
Benvenuto ospite! Login Login con Facebook Registrati Login with Facebook


Valutazione discussione:
  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5

[-]
Tags
nuovo progetto orchidee con luxometro pico per

Nuovo progetto: luxometro per orchidee con Pico
#11
Il modulo LCD può comunicare anche in I2C (questo è un esempio: https://www.youtube.com/watch?v=9XumXh7IndM). Indirizzi differenti, nel caso impostarli nei registri di ciascun dispositivo. Effettua per prima una lettura del sensore e successivamente la invii al display LCD. On-line vi sono moltissimi esempi su I2C. Una nota sulla libreria del link per il VELM7700: pur essendo in micropython non è applicabile 1 a 1 ad un pi pico, realizzata per un esp..... Contiene i parametri di configurazione e quelli di correzione, ma la libreria è vecchia di sei anni ed i valori non sono congrui con quelli del data sheet odierno. Vanno quindi verificati nel flusso del programma.
Per quanto riguarda le batterie: le batterie alcaline nuove (non "stagionate") hanno tensioni leggermente superiori a quella nominale. 4 batterie in serie potrebbero raggiungere tensioni superiori ai 6 V nominali. Per evitare problemi, a mio avviso, uno step-down non farebbe male. Valuta gli assorbimenti anche per determinare la tipologia della batteria: AAA, AA, ecc.
Risposta
#12
(04/09/2025, 20:04)ippogrifo Ha scritto: Il modulo LCD può comunicare anche in I2C (questo è un esempio: https://www.youtube.com/watch?v=9XumXh7IndM). Indirizzi differenti, nel caso impostarli nei registri di ciascun dispositivo. Effettua per prima una lettura del sensore e successivamente la invii al display LCD. On-line vi sono moltissimi esempi su I2C. Una nota sulla libreria del link per il VELM7700: pur essendo in micropython non è applicabile 1 a 1 ad un pi pico, realizzata per un esp..... Contiene i parametri di configurazione e quelli di correzione, ma la libreria è vecchia di sei anni ed i valori non sono congrui con quelli del data sheet odierno. Vanno quindi verificati nel flusso del programma.
Per quanto riguarda le batterie: le batterie alcaline nuove (non "stagionate") hanno tensioni leggermente superiori a quella nominale. 4 batterie in serie  potrebbero raggiungere tensioni superiori ai 6 V nominali. Per evitare  problemi, a mio avviso,  uno step-down non farebbe male.    Valuta gli assorbimenti anche per determinare la tipologia della batteria: AAA, AA, ecc.

questo https://www.amazon.it/Convertitori-Regol...57&sr=8-13 potrebbe andare bene?
Risposta
#13
Si va bene.
altra possibilità: https://it.aliexpress.com/item/100500709...in_prod%3A
Risposta
#14
Buonasera,
sto acquistando dei display 16X2 con input a 3,3 volt. Vorrei alimentare il Pico con 3 batterie AA. Ho degli step-down ingresso 5 volt uscita 3.3 volt. potrebbero andare bene per alimentare il Pico o è necessario comprare uno step-down 4.5 - 3.3? Che però non trovo.
Ringrazio anticipatamente
LaPa
Risposta
#15
come ti ho scritto su, se usi il pin VSYS per alimentarlo, puoi usare una tensione tra 1,8V e 5,5V.
mentre se usi VBUS o la microUSB, allora la tensione deve essere 5V.
Il pico si genera internamente i 3,3V che gli servono partendo da queste due connessioni (o una, o l'altra, altrimenti si potrebbe anche danneggiare)
Risposta
#16
(15/09/2025, 00:01)Zzed Ha scritto: come ti ho scritto su, se usi il pin VSYS per alimentarlo, puoi usare una tensione tra 1,8V e 5,5V.
mentre se usi VBUS o la microUSB, allora la tensione deve essere 5V.
Il pico si genera internamente i 3,3V che gli servono partendo da queste due connessioni (o una, o l'altra, altrimenti si potrebbe anche danneggiare)

Buonasera, 
Mi scuso per non essere stato attento. 
ok, allora collego il box che produce 4,5 volt sul 39 VSYS e poi collego il VEML7700 e il display al 36 per avere 3.3 volt. 
Comunque in altri tentativi ho collegato le batterie in modo errato collegando la microUSB al computer e la VSYS alla batteria, come mi hai fatto notare, ho rotto il Pico.

GRazieeeeeeeeeeeeee

Saluti 
LaPa
Risposta
#17
Salve, 
ho comprato il sensore. 
ho usato questi scrip, segnalati da Ippogrifo. Non ne ho trovati altri. Ho scritto anche al produttore il quale non mi ha ancora risposto. 

Codice:
# Copyright (c) 2019 Joseph Hopfmüller
# This module is a fork of Christophe Rousseaus module.
# see: https://github.com/palouf34/veml7700.git
#
# Original coypright notices are reproduced below.
# Changes:
#  - fixed critical error in value calculation
#  - restructured the constants into dictionaries
#      -> with this you have to pass the integration time and gain when initializing the module
#
#
# 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.
#
#
#
# Original copyright notices:
#
# Authors: Christophe ROUSSEAU, 2019
#
# This module borrows from the DFROBOT VEML7700 Python library. Original
# Copyright notices are reproduced below.
#
# Those libraries were written for the NODEMCU(LOLIN). This modification is
# intended for the MicroPython and esp8266 boards.
#
#
# Based on the BH1750 driver with VMEL7700 changes provided by
# Auteur : iTechnoFrance
#
#
# 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.

from machine import I2C, Pin
import time
from micropython import const

#start const
# default address
addr = const(0x10)

# Write registers
als_conf_0 = const(0x00)
als_WH = const(0x01)
als_WL = const(0x02)
pow_sav = const(0x03)

# Read registers
als = const(0x04)
white = const(0x05)
interrupt = const(0x06)

#gain            0.125                    0.25                    1                        2                        integration time
confValues = {  25: {1/8: bytearray([0x00, 0x13]), 1/4: bytearray([0x00,0x1B]), 1: bytearray([0x00, 0x01]), 2: bytearray([0x00, 0x0B])}, #25
                50: {1/8: bytearray([0x00, 0x12]), 1/4: bytearray([0x00,0x1A]), 1: bytearray([0x00, 0x02]), 2: bytearray([0x00, 0x0A])}, #50
                100:{1/8: bytearray([0x00, 0x10]), 1/4: bytearray([0x00,0x18]), 1: bytearray([0x00, 0x00]), 2: bytearray([0x00, 0x08])}, #100
                200:{1/8: bytearray([0x40, 0x10]), 1/4: bytearray([0x40,0x18]), 1: bytearray([0x40, 0x00]), 2: bytearray([0x40, 0x08])}, #200
                400:{1/8: bytearray([0x80, 0x10]), 1/4: bytearray([0x80,0x18]), 1: bytearray([0x80, 0x00]), 2: bytearray([0x80, 0x08])}, #400
                800:{1/8: bytearray([0xC0, 0x10]), 1/4: bytearray([0xC0,0x18]), 1: bytearray([0xC0, 0x00]), 2: bytearray([0xC0, 0x08])}} #800

#gain              0.125,  0.25,  1,      2      integration time
gainValues = {  25: {1/8: 1.8432, 1/4: 0.9216, 1: 0.2304, 2: 0.1152}, #25
                50: {1/8: 0.9216, 1/4: 0.4608, 1: 0.1152, 2: 0.0576}, #50
                100:{1/8: 0.4608, 1/4: 0.2304, 1: 0.0288, 2: 0.0144}, #100
                200:{1/8: 0.2304, 1/4: 0.1152, 1: 0.0288, 2: 0.0144}, #200
                400:{1/8: 0.1152, 1/4: 0.0576, 1: 0.0144, 2: 0.0072}, #400
                800:{1/8: 0.0876, 1/4: 0.0288, 1: 0.0072, 2: 0.0036}} #800


# fin des constante

# Reference data sheet Table 1 for configuration settings

interrupt_high = bytearray([0x00, 0x00]) # Clear values
# Reference data sheet Table 2 for High Threshold

interrupt_low = bytearray([0x00, 0x00]) # Clear values
# Reference data sheet Table 3 for Low Threshold

power_save_mode= bytearray([0x00, 0x00]) # clear values
# Reference data sheet Table 4 for Power Saving Modes


class VEML7700:

    def __init__(self,
                address=addr,
                i2c=None,
                it=25,
                gain=1/8,
                **kwargs):
     
        self.address = address
        if i2c is None:
            raise ValueError('An I2C object is required.')
        self.i2c = i2c

        confValuesForIt = confValues.get(it)
        gainValuesForIt = gainValues.get(it)
        if confValuesForIt is not None and gainValuesForIt is not None:
            confValueForGain = confValuesForIt.get(gain)
            gainValueForGain = gainValuesForIt.get(gain)
            if confValueForGain is not None and gainValueForGain is not None:
                self.confValues = confValueForGain
                self.gain = gainValueForGain
            else:
                raise ValueError('Wrong gain value. Use 1/8, 1/4, 1, 2')
        else:
            raise ValueError('Wrong integration time value. Use 25, 50, 100, 200, 400, 800')

        self.init()

    def init(self):
     
        # load calibration data
        #self.i2c.writeto_mem(self.address, als_conf_0, bytearray([0x00,0x13]) )
        self.i2c.writeto_mem(self.address, als_conf_0, self.confValues )
        self.i2c.writeto_mem(self.address, als_WH, interrupt_high )
        self.i2c.writeto_mem(self.address, als_WL, interrupt_low)
        self.i2c.writeto_mem(self.address, pow_sav, power_save_mode)
       
    def detect(self):
        """ Functions is  verified is  module has detecedself.

        this function not implemented for this time
        """
        None
       
    def read_lux(self):
        """ Reads the data from the sensor and returns the data.
           
            Returns:
              the number of lux detect by this captor.
        """
      #The frequency to read the sensor should be set greater than
        # the integration time (and the power saving delay if set).
        # Reading at a faster frequency will not cause an error, but
        # will result in reading the previous data

        self.lux = bytearray(2)
       
        time.sleep(.04)  # 40ms

        self.i2c.readfrom_mem_into(self.address, als, self.lux)
        self.lux= self.lux[0]+self.lux[1]*256
        self.lux=self.lux*self.gain
        return(int(round(self.lux,0)))
       


e questo per la lettura: 

Codice:
#standard libraries
from machine import Pin, I2C

#this library
import veml7700

#setup i2c bus
sda=machine.Pin(0)
scl=machine.Pin(1)
i2c=machine.I2C(0, sda=sda, scl=scl, freq=10000)
#i2c = I2C(0)
#i2c = I2C(1, scl=Pin(1), sda=Pin(0), freq=10000)

#setup sensor with intergartion time 100 ms and gain 1/8
veml = veml7700.VEML7700(address=0x10, i2c=i2c, it=100, gain=1/8)

#read the ambient light brightness
lux_val = veml.read_lux()

Purtropo mi dà quest'errore:

Codice:
Traceback (most recent call last):
  File "<stdin>", line 15, in <module>
  File "veml7700.py", line 142, in __init__
  File "veml7700.py", line 148, in init
OSError: [Errno 5] EIO

Mi sapreste dare una mano?

Grazie 

Saluti 

LaPa
Risposta
#18
Dall'errore sembra che il sensore non venga riconosciuto.
Verifica che sia alimentato correttamente e che l'indirizzo I2C sia rispondente a quello della libreria [addr = const(0x10)]. Nel caso fai una scansione degli indirizzi con "i2c.scan()". Link: https://docs.micropython.org/en/latest/l...e.I2C.html

P.S.
Dal datasheet del sensore, potrebbero essere necessarie delle resistenze di pull-up sulle linee SDA e SCL al fine di rendere univoco lo stato delle linee.
Risposta
#19
(28/09/2025, 06:40)ippogrifo Ha scritto: Dall'errore sembra che il sensore non venga riconosciuto.
Verifica che sia alimentato correttamente e che l'indirizzo I2C sia rispondente a quello della libreria [addr = const(0x10)]. Nel caso fai una scansione degli indirizzi con "i2c.scan()". Link: https://docs.micropython.org/en/latest/l...e.I2C.html

P.S.
Dal datasheet del sensore, potrebbero essere necessarie delle resistenze di pull-up sulle linee SDA e SCL al fine di rendere univoco lo stato delle linee.

Grazie per la risposta
Ho risolto, il problema era la frequenza: l'ho indicata a 40000 invece che 10000
Saluti
LaPa

p. s. il progetto continua Wink ed è a buon punto, poi pubblico tutto
Risposta
#20
Buonasera a tutti,
sono arrivato a montare il sensore sulla breadboard e farlo funzionare  con 3 pile AA. Fa letture continue.
2 problemi:
1) l'ho testato all'aperto e mi sembra che i valori rilevati sembrano essere molto lontani da quelli che mi aspettavo. IO penso che il problema sia sempre la libreria in Micropython, ho un po' modificato, con al formula di correzione da applicare per letture sopra i 1000 lux. Penso che una libreria seria cambi in automatico i parametri "IT" e il "GAIN", Come è descritto nel Datasheet del sensore, ma io non so farlo.
Pensavo allora di usare la libreria di Adafruit che è in CircuitPython che mi sembra più aggiornata. Non ho capito bene però  come s'installa  adafruit-circuitpython-veml7700 sul pico.
Preparerei un altro pico con CircuitPython, con un altro sensore e poi faccio il confronto tra le librerie. 
Vi vengono in mente dei problemi nel perseguire questa strada?
2) ho utilizzato per le prove un vecchio display che però ha l'ingresso a  5V io lo sto usando a 3,3 V. e questo è veramente fioco per cui in pieno sole non si riesce a vedere chiaramente. Sono in attesa di altri display  https://it.aliexpress.com/item/100500393...pt=glo2ita spero di riuscire a risolvere.

Vi ringrazio per i suggerimenti
Saluti
LaPa
Risposta
  


Vai al forum:


Navigazione: 1 Ospite(i)
Forum con nuovi Post
Forum senza nuovi post
Forum bloccato
Forum Redirect