Principles

  • Use a BH1750 to measure environment light
  • Use a special Arduino Nano at 3V3

The result

lightsensor with arduino uno

lightsensor with arduino uno

backside of the lightsensor with arduino uno

backside of the lightsensor with arduino uno

Used Components

Wiring

Component Pin Wire/Component Pin Component
BH1750-Light-Sensor VCC red VCC Arduino Uno
BH1750-Light-Sensor GND black GND Arduino Uno
BH1750-Light-Sensor SCL SCL Purple Arduino Uno
BH1750-Light-Sensor SDA SDA Green Arduino Uno

Programming

  • Select as board: Arduino Uno
  • Processor: ATmega328P (3.3V, 16MHz)
  • Serial monitor: 19200 Baud
  • Use platformio

Code at: LightSensor.ino

I2C scanner

The I2C scanner software gives:

Scanning...
I2C device found at address 0x23  !
done

First sign of life

Second attempt, after clearing the eeprom of the Arduino. You can see here how an ID is requested from the gateway, and the gateway assigned number 4:

__  __       ____
|  \/  |_   _/ ___|  ___ _ __  ___  ___  _ __ ___
| |\/| | | | \___ \ / _ \ `_ \/ __|/ _ \| `__/ __|
| |  | | |_| |___| |  __/ | | \__ \  _  | |  \__ \
|_|  |_|\__, |____/ \___|_| |_|___/\___/|_|  |___/
        |___/                      2.3.2

104 MCO:BGN:INIT NODE,CP=RNNNA---,FQ=16,REL=255,VER=2.3.2
168 TSM:INIT
175 TSF:WUR:MS=0
189 TSM:INIT:TSP OK
199 TSM:FPAR
207 ?TSF:MSG:SEND,255-255-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
297 TSF:MSG:READ,0-0-255,s=255,c=3,t=8,pt=1,l=1,sg=0:0
326 TSF:MSG:FPAR OK,ID=0,D=1
347 TSF:MSG:READ,14-14-255,s=255,c=3,t=8,pt=1,l=1,sg=0:1
779 TSF:MSG:READ,17-17-255,s=255,c=3,t=8,pt=1,l=1,sg=0:2
1078 TSF:MSG:READ,20-20-255,s=255,c=3,t=8,pt=1,l=1,sg=0:1
1596 TSF:MSG:READ,117-117-255,s=255,c=3,t=8,pt=1,l=1,sg=0:3
2247 TSM:FPAR:OK
2255 TSM:ID
2263 TSM:ID:REQ
2272 TSF:MSG:SEND,255-255-0-0,s=215,c=3,t=3,pt=0,l=0,sg=0,ft=0,st=OK:
2309 TSF:MSG:READ,0-0-255,s=215,c=3,t=4,pt=0,l=1,sg=0:4
2338 TSF:SID:OK,ID=4
2350 TSM:ID:OK
2357 TSM:UPL
2368 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2404 TSF:MSG:READ,0-20-255,s=215,c=3,t=4,pt=0,l=1,sg=0:4
2434 TSF:MSG:BC
2443 TSF:MSG:READ,0-0-4,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2471 TSF:MSG:PONG RECV,HP=1
2486 TSM:UPL:OK
2494 TSM:READY:ID=4,PAR=0,DIS=1
2547 !TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=NACK:0100
2586 TSF:MSG:READ,0-17-255,s=215,c=3,t=4,pt=0,l=1,sg=0:4
2616 TSF:MSG:BC
2625 TSF:MSG:READ,0-20-255,s=215,c=3,t=4,pt=0,l=1,sg=0:4
2655 TSF:MSG:BC
2663 TSF:MSG:READ,0-117-255,s=215,c=3,t=4,pt=0,l=1,sg=0:4
2694 TSF:MSG:BC
4590 TSF:MSG:SEND,4-4-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=1,st=OK:2.3.2
4629 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4665 TSF:MSG:READ,0-0-4,s=255,c=3,t=6,pt=0,l=1,sg=0:M
4696 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=11,pt=0,l=19,sg=0,ft=0,st=OK:Light Sensor BH1750
4745 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
4786 TSF:MSG:SEND,4-4-0-0,s=1,c=0,t=16,pt=0,l=11,sg=0,ft=0,st=OK:Light - Lux
4826 !MCO:SND:NODE NOT REG
4840 MCO:REG:REQ
4853 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
4889 TSF:MSG:READ,0-0-4,s=255,c=3,t=27,pt=1,l=1,sg=0:1
4918 MCO:PIM:NODE REG=1
4930 MCO:BGN:STP
Light Sensor BH1750 1.0 Channel 125 - Online!
4979 MCO:BGN:INIT OK,TSP=1
Wake up - now minute 0
5194 TSF:MSG:SEND,4-4-0-0,s=1,c=1,t=37,pt=7,l=5,sg=0,ft=0,st=OK:16
Ambient light luminance: 15.83 lux.
5230 MCO:SLP:MS=60000,SMS=0,I1=255,M1=255,I2=255,M2=255
5278 TSF:TDI:TSL
Tags: domotica nodes
Comments: