formtapez / ZigUP

CC2530 based multi-purpose ZigBee Relais, Switch, Sensor and Router
314 stars 73 forks source link

illuminance sensor #4

Closed anshgh closed 4 years ago

anshgh commented 4 years ago

Hi Can I make a light sensor (illumination) with a BH1750?

formtapez commented 4 years ago

The processor doesnt have a TWI interface, so its not possible. But you can use an analog sensor like a photoresistor or solar-cell on the analog-input pin.

anshgh commented 4 years ago

Tanks. I need high resolution illuminance. Because my sensor Aqara Motion Sensor gives a maximum of 1000 Lx and in cloudy and sunny weather. image (6) image (5) Do you know the illuminance sensor with WTI support?

anshgh commented 4 years ago

Which pins of the CC2530 (P00-P22) correspond to the pins on your board (Sensor, S0, ADC, DIG, LED, KEY)?

formtapez commented 4 years ago

Just have a look in the schematic.

anshgh commented 4 years ago

Tanks. Can I buy such a module on Aliexpress? image Will this module work? https://ru.aliexpress.com/item/32999369655.html

anshgh commented 4 years ago

or - https://ru.aliexpress.com/item/32982000600.html

formtapez commented 4 years ago

These are no illumination sensors. But if you want to measure rotation angle, you can use them.

anshgh commented 4 years ago

Yes. I know. This is a variable resistor to replace (not solder) the element X2-3 to ADC0. https://user-images.githubusercontent.com/8523569/61642187-2a431280-aca9-11e9-967b-9c66f99e5a8b.png

I want to use the TEMP6000 light sensor. He is 5 volt. But in your circuit to ADC0 you need 1.15 volts. Therefore, I want to use a variable resistor (links above) to connect the TEMP6000. It is right?

formtapez commented 4 years ago

I dont think that works. The current is too low to drive the ADC. You need an active component there.

anshgh commented 4 years ago

Why? It works for me on esp8266.

anshgh commented 4 years ago

Can you help turn on the deep sleep mode for the CC2530 for 2 minutes in your firmware?

anshgh commented 4 years ago

The processor doesnt have a TWI interface, so its not possible. But you can use an analog sensor like a photoresistor or solar-cell on the analog-input pin.

https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/p/824148/3049477#3049477 https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/t/140917

anshgh commented 4 years ago

The processor doesnt have a TWI interface, so its not possible. But you can use an analog sensor like a photoresistor or solar-cell on the analog-input pin.

I want to use a TEMP6000 sensor. How often will data from analog sensors be transmitted? Can I change this time?

formtapez commented 4 years ago

You can change the reporting interval (default: 30s) here: https://github.com/formtapez/ZigUP/blob/ec3112c4933cfd9b377bc32b3dd97cde0bd6086c/src/ZigUP/Source/zcl_zigup.c#L28

anshgh commented 4 years ago

What is adc_volt":2.259? I connected TEMP6000 3.3v. in you the schematic ADC0 = 1.15v zigbee2mqtt:info 8/14/2019, 3:16:25 PM MQTT publish: topic 'zigbee2mqtt/0x00124b001d6663ed', payload '{"state":"OFF","cpu_temperature":24.48,"external_temperature":null,"external_humidity":null,"s0_counts":0,"adc_volt":2.259,"dig_input":1,"reason":"timer","linkquality":134}'

formtapez commented 4 years ago

that seems pretty correct for me. you can measure up to 32 volt due to that resistor-divider at the input.

anshgh commented 4 years ago

What you need to enable sleep mode (PM2). "You can define POWER_SAVING in project predefined symbols to enable it. After you define POWER_SAVING, CC2530 will enter sleeping mode automatically when there’s nothing in osal task queue." Enable a compile option, del an "x" at the left edge of the line or add POWER_SAVING.

image

Awakening interval can be configured in the file zcl_zigup.c : #define ZIGUP_REPORTING_INTERVAL 120000 (120sec)

Other than report interval, polling rate would wake up device every second by default. You can change polling rate by changing -DPOLL_RATE in f8wconfig.cfg. -DPOLL_RATE=120000

anshgh commented 4 years ago

I also changed the code in zcl_zigup.c to turn off the voltage of the TEMP6000 sensor during sleep mode. I connected TEMP6000 to 3.3v = P1.6 and data = P0.0 added:

LED(1);
_delay_ms(1000);
Measure_QuickStuff();
Measure_Sensor();
LED(0);

image

commented: //LED(1);

image