@maghac @moskovskiy82 I came across this some time ago, with an RGB LED project. Whilst I can't recall the details, it's to do with setting the Arduino's PWM timers - apparently, the frequencies of the R(ed) & B(lue) channels can be close enough to causing 'beating', which gives rise to flickering. This statement changes the frequency of one of the channels slightly, thereby eliminating the flickering.
Posts made by MikeF
-
RE: RGB LED strip
-
RE: Enclosure
Separately from this, you can find a local 3d-printing service on 3dhubs.com - I found one local to me this way, who did my first print, which got me onto the 3d trail (I subsequently bought a Prusa i3 MkII kit).
-
RE: Enclosure
...or you can use a 3d-printing service - email them the stl file (follow @dbemowsk's link above, to his Thingiverse page).
-
RE: HDC1080 battery operated temp/humidity sensor with wall box
Your box looks really good!
Re bevelling: I did a quick Google for 'openscad bevel' - haven't looked at the results, don't know if any of these are what you want.
-
RE: HDC1080 battery operated temp/humidity sensor with wall box
I've used openSCAD a few times now, to print enclosures, including MySensors and RaspberryPi's (note to self: must publish these here / on Thingiverse), and I like the way you can precisely define shapes through its structured language.
I recently came across an RPi case with rounded corners and edges, which was simply achieved by creating small spheres at each of the corners, and then producing a 'hull' around them:
Here's some simple code which I used to create the above examples:// Rounded box example r = 2; box = [80, 40, 20]; hull_build(box,r); //Utility module to make a solid box with rounded corners module hull_build(box,r){ //spheres at the corners of a box and run hull over it x = box - 2 * [r,r,r]; difference(){ hull(){ for (i=[0:1]){ for (j=[0:1]) { for (k=[0:1]){ translate([i*x[0],j*x[1],k*x[2]]+[r,r,r]) //move up r because we moved box up sphere(r); } } } } } }
-
RE: What options are there for wireless wifi power-plugs with energy-monitoring?
I'm using one of these : http://uk.tp-link.com/products/details/cat-5258_HS110.html
I've written a Python script to read this in Domoticz (not MySensors though).
-
RE: Domoticz now supports the MySensors MQTT Gateway
Got this working OK. I built a MQTT / W5100 gateway as per the instructions in the MySensors Build section, and changed the topic prefixes and controller IP address in the example sketch.
Initially this failed, as I had connected Vcc on the W5100 to 5V instead of 3.3V, and I had the prefixes the wrong way round (i.e., /out instead of /in).
(BTW: I'm using MySensors 2.1.0 and Domoticz 3.6371 - latest / recent beta.)
-
RE: Domoticz now supports the MySensors MQTT Gateway
@jpaulin said:
@MikeF
Domoticz can now interpret the MySensors MQTT format from a MySensors MQTT Client Gateway without JSON stuff, it's straight forward. To make it work just change the Topic Prefix in the MySensors Gateway and the rest is solved under the hood. Auto discovery etc works now as any other MySensors Gateway with Domoticz.Thanks for this, @jpaulin - I'll build an MQTT / ethernet gateway and see how I get on.
-
RE: Domoticz now supports the MySensors MQTT Gateway
Hi @jpaulin, can you explain how you got this working with MySensors?
As far as I can tell, MySensors and Domoticz use very different MQTT message formats.
Some examples:
MySensors:mygateway1-out/2/1/1/0/49 55.722519;13.018121;13
Domoticz:
{ "idx" : 222, "nvalue" : 0, "svalue" : "22.5" }
Note: I can publish to the 'domoticz/in' topic from the command line OK:
mosquitto_pub -h 192.168.0.63 -m '{ "idx" : 222, "nvalue" : 0, "svalue" : "22.5" }' -t 'domoticz/in'
(this updates a dummy temperature node in Domoticz) , so I know that MQTT is working in Domoticz.
-
RE: Fire pit RGB striplight controller
Be careful powering the Nano from 12V - there are reports elsewhere on this forum of some versions getting fried at this voltage!
-
RE: PCB Boards for MySensors
Is there a 'local' source of PCBs for MySensors (i.e., UK / Europe)?
I've just (14 November) received 3 of @sundberg84's Low Power Node PTH v2 (atmega328p and NRF24L01+) boards from OSH Park in the US, which I ordered on 24 October - panelisation and fabrication was actually quick, and they were finished and posted on 2 November. Elapsed time was 3 weeks, but I understand it can be up to twice this for boards from China (e.g., dirtypcb's).
It would be good if there was a more local source, with shorter elapsed times.
-
RE: Mini Weather Station
I've now uploaded an external view - see my earlier post.
-
RE: Mini Weather Station
... and here's mine - in white:
(now managed to upload pics in portrait!)I'm using a BME280 instead of a BMP180 and DHT22.
-
RE: EU flag development board
@ceech, could you make a version for the UK - without the flag?
-
RE: Problems with V_TEXT in MySensors 2.0.0
Thanks, @AWI - using wait() instead of sleep() works.
However, isn't there an issue for battery-powered nodes in using wait rather than sleep? Sleep worked OK on my sketch under MySensors 1.5 - maybe the use of gw.begin(incomingMessage, NODE_ID) woke it up?
Will this also be the case with other sketches which receive messages from the controller? for example, I have still to convert an RGB LED sketch which gets a hex value (in the form 0xrrggbb) from the controller?
-
Problems with V_TEXT in MySensors 2.0.0
I've been converting my sketches to MySensors 2.0.0, and I seem to have hit a problem with a node using V_TEXT and S_INFO, getting a text value from Domoticz. Previously - under 1.5 - I had added V_TEXT and S_INFO to MyMessage.h, and this worked OK. (I have a text sensor in Domoticz, and typically this has a value such as 10.3#77#3, which I'm parsing in the sketch.)
Now, however, I cannot get the sketch to read the value.
I've stripped the sketch down to the bare basics here:
// Text Sensor // MySensors 2.0.0 #define MY_DEBUG #define MY_RADIO_NRF24 #define MY_RF24_CE_PIN 7 #define MY_RF24_CS_PIN 8 #define MY_NODE_ID 40 #include <MySensors.h> #define SKETCH_NAME "Text sensor" #define SKETCH_MAJOR_VER "2.0" #define TEXT_CHILD_ID 11 unsigned long SLEEP_TIME = 30000; // 0.5 min. (300 sec.) sleep time between reads (seconds * 1000 milliseconds) String tempSensor; String outsideTemp; MyMessage textMsg(TEXT_CHILD_ID, V_TEXT); void presentation() { // Send the sketch version information to the gateway and Controller sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER); present(TEXT_CHILD_ID, S_INFO); } void setup() { } void loop() { request(TEXT_CHILD_ID, V_TEXT); // Sleep until something happens with the sensor sleep(SLEEP_TIME); } void receive(const MyMessage &message) { if (message.type == V_TEXT) { tempSensor = message.getString(); int sepIndex = tempSensor.indexOf('#'); outsideTemp = tempSensor.substring(0, sepIndex); Serial.println(tempSensor); } }
The main difference was changing 'void incoming Message' to 'void receive'.
I've included a sample of the serial output here:
TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok: TSP:MSG:SEND 40-40-0-0 s=11,c=2,t=47,pt=0,l=0,sg=0,ft=0,st=ok:
The sketch seems to be sending out empty text strings, but not issuing any reads.
Any clues? Thanks in anticipation.
-
RE: My Gateway
Inspired by this, I eventually got round to making a smaller gateway:
I'm powering this from a 5V USB source, with an AM1117 3.3V regulator for the radio.
I also took the opportunity to use the MySensors 2.0.0 Serial Gateway example, and to convert my existing sketches - I followed this thread.
-
RE: Multisensor node using Ceech board
I've built nodes using two versions of the Ceech board intended for solar cells - one with the LTC4079 charger, the other with the earlier LTC4067 charger.
I now want to use one of these as a pulse power sensor without sleep (as per MySensors example sketch), so it needs to be on non-battery power, i.e., from a 5V USB charger. If I remove the battery, which input should I connect the 5V to: the battery input or the solar input?
-
RE: Ethernet Gateway debug to LCD
If you've got an Android phone, an alternative would be to connect an HC-05 Bluetooth module (Tx, Rx, Vcc, GND), and use an app such as BlueTerm to monitor the serial output.
-
RE: Ceech-Board Buyers
I've ordered 3 at different times, and always received them directly through my letterbox from Slovenia within a week - I'm in the UK. I'm also very impressed with the quality and functionality of the boards.
-
RE: Multisensor node using Ceech board
@ceech That did it - thanks!
Currently charging at c. 90mA:
Vcc = 3.30V
Charge current = 89.93mA
Solar cell voltage = 4.95V
Battery voltage = 3.62V
CHRG = 0 -
RE: Multisensor node using Ceech board
@ceech I've connected a 5V USB supply to the solar cell input, and I'm running your example sketch from your eBay web page for this board. I'm seeing a battery voltage of 3.59V (Li-ion), and charge current (monitoring A6) of 0.00mA - suggesting the battery isn't charging? As said before, A7 is showing values around 479.
Vcc = 3.30V
Charge current = 0.00mA
Solar cell voltage = 4.98V
Battery voltage = 3.59V
CHRG = 479 -
RE: PWM frequencies on pin 9,10,11
I've found that adding this to setup() can cure flickering:
//Increase Timer frequency to prevent flicker in Pins 5,6 PWM TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
-
RE: Multisensor node using Ceech board
@ceech I'm using a more recent version of this board, with an LTC4079 charger (instead of the LTC4067).
Which Arduino pin is the ~CHRG signal brought out on? A2 appears to be Vin (solar cell), whereas if I do analogRead(A7) I get a value around 500 (regardless of whether Vin is connected or not)?
-
RE: Universal board bought from from Slovenia Radio Woes. (solved)
@chickey Interesting - no such requirement on the version I'm using. Instead, D3 is used to drive a MOSFET with an uncommitted drain, which can be used to drive a relay - or LED strip, as D3 is a PWM output.
-
RE: Universal board bought from from Slovenia Radio Woes. (solved)
I'm using the solar cell version of this board (here), and I've made the same transport change as you - been using this for over 9 months now, without problems.
Which version of the MySensors library are you using (I'm on 1.5)?
-
RE: Control leds with a mosfet
For an N-channel MOSFET such as IRLML2502, source should go to GND and drain to 12V via the LED strip, as in your diagram (I'm assuming you're using common-cathode LED strips?).
Can you check the pinout of the MOSFET? The datasheet shows different pin numbers: IRLML2502
-
RE: RGBW Strip WireLess Shield V1.0
What's the current capacity - and therefore max. no. of LEDs - per channel? (I guess I was expecting to see some chunky TO-220 MOSFETs!)
-
RE: How to send initial RGB dimmer values to Domoticz?
Thanks, @BumblingWelsh , I'll check this out - but it looks as though it's for a Neopixel strip, and I'm using an analogue one.
-
RE: MySensors shield and RGBW Controller
Hi @LastSamurai, I've loaded your sketch onto my RGBW controller, and had a look.
I discovered a number of issues:
- in updateLights(), under '// for each color', the limit on the 'for' loop should be v < NUM_CHANNELS (not v<= ... - this was corrupting channels[0])
- under '// set actual pin values', I had trouble with the exponential dimming, so I commented out this line, and uncommented the alternative analogWrite statement 2 lines above
- dimming and target_dimming should be declared as type 'float', otherwise the calculation dimming / 100 * values[i] rounds down to zero (the LEDs were switching off)
- on an Arduino Nano and Pro Mini (at least), PWM outputs are restricted to D3, 5, 6, 9, 10, 11 - you have defined WHITE_PIN as D4.
With these changes, it seems to work OK - I didn't get any 'st=fail' errors; are you supplying the radio from a separate 3.3V supply (not from the Arduino), and have you added a capacitor (usually 4.7uF) across the supply pins?
-
How to send initial RGB dimmer values to Domoticz?
I've set up an RGB dimmer in Domoticz using V_RGB, and I want to be able to turn on the dimmer in Domoticz and send initial RGB values when my sketch starts. I've tried various combinations of gw.send and gw.request within setup(), to no avail - the dimmer stays resolutely off. The only way I can 'wake it up' is by clicking / dragging in the colourspace.
What do I need to do?
-
RGB colorpicker
I've recently built an RGB/W controller (here), and I've been developing a sketch using V_RGB to select colours from a colourspace (as opposed to the 3 x V_DIMMER approach).
I'm using Domoticz, but I'm not very happy with the Domoticz colour picker - it only appears to support colours with 100% saturation, and the RGB values shown don't seem to equate to the values received in the sketch.
I went looking for a different colour picker, and I came across this. As stated, 'the application consists of Java application that serves as the colorpicker interface and an Arduino Sketch that receives RGB colors and applies them to the PWM pins.'
I'm currently running it on a Mac, and I needed to add the parameter '-d32' to the java command in ledcolorpicker.sh (as well as specifying my USB serial port) as the librxtxSerial.jnilib library is 32-bit, not 64-bit. Also, it outputs lots of messages to the terminal / console (I suspect these are debug messages, and can be turned off).
So it's rather old and clunky, but it works...
Does anyone know of an alternative colour picker solution, which will interface with an Arduino?
-
RE: Ultrasonic essential Oil diffuser
...think we need a new sensor type: V_ESSENTIAL_OIL_DIFFUSER
-
RE: Requesting variables from Domoticz
@mfalkvidd said:
- t=23: the message type is 23 - which isn't a valid message type according to the serial API documentation
Following your comment earlier in this thread, I copied V_TEXT and S_INFO from the development branch into MyMessage.h. V_TEXT occupies position 47 in the typedef enum for '//Type of sensor data' in my version of MyMessage.h - when you copied it, did it go into position 23?
-
RE: RGBW Controller kit
OK, I'm starting to understand HSV better - and I've been reading this thread. I understand that Domoticz currently (although gizmocuz states this is due to change) only allows you to change Hue and Brightness (V), but not Saturation. Is there any other way of changing all 3 values, and sending them to a MySensors RGB node (*) - e.g., using V_TEXT (with suitable conversion from HSV to RGB)?
(* I'm currently looking at RGB, not RGBW, as I'm using a separate white strip - I've set up a simple sketch with V_RGB, and V_DIMMER for white.)
-
RE: Dsiplaying dimmer percentage in Domoticz
Are you sure that you included the lines below '// Clip incoming level to valid range of 0 to 100'? Values from Domoticz should be in the range 0 to 100 (%), whereas values sent to the pins (LEDs) in fadeToLevel() are converted to the range 0 to 255.
-
RE: RGBW Controller kit
@LastSamurai I accept that using sliders gives quite a coarse level of control - Domoticz only provides 16 steps on a slider (corresponding to increments of 6 - 7%), so the lowest blue, for instance, is 7%.
IR basically works in this sketch by loading stored % dimmer values from eeprom, incrementing / decrementing them, storing updated values, sending them to the controller, and outputting corresponding values (0 - 255) to the PWM pins. All I've tried to do so far is to emulate what was in Custom Geek's sketch. Currently it increases the % levels by 10 (e.g., 40 / 50 / 60 / 50 / 40). I realise that this can be made to provide finer control than the sliders in Domoticz, e.g., +/- 5.
I'm going to have another look at the Domoticz colour picker, but as I said, I find it difficult to use.
@fets The colour picker you showed already exists in Domoticz stable 2.3530.
-
RE: RGBW Controller kit
Hi @LastSamurai , I'm using Domoticz as my controller. I've followed this thread and this one (as you may recall, we communicated on this), and I was concerned about Domoticz support for RGBW dimmers.
I've tried your RGBWDimmer sketch, and it works well, but I find I can't get on with the current Domoticz colour picker. Also, I plan to run separate RGB and W strips, so I've gone for the 4-dimmer approach.
-
RE: RGBW Controller kit
Here's the sketch I've developed. It's based on the Dimmable LED With Rotary Encoder, which I extended to 4 channels, and added some IR methods based on Jeremy Saglimbeni's sketch.
The sketch saves updated LED levels in eeprom, so that these survive any power interruption, and provides a simple fade up / down to new levels.
The sketch uses PWM outputs 3, 5, 9 & 10 for the LEDs, and pins 6 & 7 for the CE & CS pins on the radio. The choice was limited by the particular board I'm using, but in practice it should be possible to use this sketch on other RGB / RGBW controllers.
As documented in the sketch, the IR uses a TSOP38238 IR receiver and Adafruit Mini Remote Control, with the Adafruit_NECremote library. I've emulated most - but not all - of the IR commands in the original CustomGeek sketch. IR commands update the LED levels, and send these levels to the controller (I'm using Domoticz). If you don't want to use IR, you can simply remove the hearir() statement in the loop() method (line 140).
/** * The MySensors Arduino library handles the wireless radio link and protocol * between your home built sensors/actuators and HA controller of choice. * The sensors forms a self healing radio network with optional repeaters. Each * repeater and gateway builds a routing tables in EEPROM which keeps track of the * network topology allowing messages to be routed to nodes. * * Created by Henrik Ekblad <henrik.ekblad@mysensors.org> * Copyright (C) 2013-2015 Sensnology AB * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors * * Documentation: http://www.mysensors.org * Support Forum: http://forum.mysensors.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * ******************************* * * REVISION HISTORY * Version 1.0 - Developed by Bruce Lacey and GizMoCuz (Domoticz) * Version 1.1 - Modified by MikeF to provide 4 dimmers: RGBW * and simple IR control: toggle / up / down, with inspiration * from Jeremy Saglimbeni (www.thecustomgeek.com) * * DESCRIPTION * RGBW LED strip controlled with 4 dimmers, with simple fade up / down. * Uses TSOP38238 IR receiver with Adafruit NEC Remote Control to provide * remote control, as well as operation through gateway / controller. * * ---------------------------------------------------* * IR Commands: * * Remote Key NEC Code Command * * ---------------------------------------------------* * vol- 0 (not used) * * play/pause 1 (not used) * * vol+ 2 (not used) * * setup 4 white toggle * * up 5 bright - RGB * * stop/mode 6 all off * * left 8 white down * * enter/save 9 (not used) * * right 10 white up * * 0/+10 12 all on * * down 13 dim - RGB * * repeat 14 show RGBW values * * 1 16 red up * * 2 17 green up * * 3 18 blue up * * 4 20 red toggle * * 5 21 green toggle * * 6 22 blue toggle * * 7 24 red down * * 8 25 green down * * 9 26 blue down * * ---------------------------------------------------* */ #include <SPI.h> #include <MySensor.h> #include "Adafruit_NECremote.h" #define RED_PIN 9 #define GREEN_PIN 10 #define BLUE_PIN 5 #define WHITE_PIN 3 #define IRpin 2 Adafruit_NECremote remote(IRpin); #define SN "Dimmable RGBW LED" #define SV "1.1" int r = 1; int g = 2; int b = 3; int w = 4; int i; int RGB_pins[5] = {0, RED_PIN, GREEN_PIN, BLUE_PIN, WHITE_PIN}; int toggleBtns[] = {0, 20,21,22,4}; // NEC codes for remote buttons - see table above int upBtns[] = {0, 16, 17, 18, 10}; int downBtns[] = {0, 24, 25, 26, 8}; int FADE_DELAY = 25; // ms between fade steps char convBuffer[10]; int oldLevel; int newLevel; int remval; int oldc; MyTransportNRF24 transport(6,7); // (default: 9, 10 - changed for my board) MySensor gw(transport); MyMessage RedStatus(r, V_DIMMER); MyMessage GreenStatus(g, V_DIMMER); MyMessage BlueStatus(b, V_DIMMER); MyMessage WhiteStatus(w, V_DIMMER); // Serial.print translate sensor id to sensor name char color[][6] = {"","RED","GREEN","BLUE","WHITE"}; void setup() { // Set analog led pin to off analogWrite( RED_PIN, 0); analogWrite( GREEN_PIN, 0); analogWrite( BLUE_PIN, 0); analogWrite( WHITE_PIN, 0); // Init mysensors library gw.begin(incomingMessage, 31, false); // Register sensors (id, type, description, ack back) gw.present(r, S_DIMMER, "RED LEDs"); gw.present(g, S_DIMMER, "GREEN LEDs"); gw.present(b, S_DIMMER, "BLUE LEDs"); gw.present(w, S_DIMMER, "WHITE LEDs"); // Send the Sketch Version Information to the Gateway gw.sendSketchInfo(SN, SV); // Retrieve our last dim levels from the eprom Serial.println("Sending in last known light levels to controller: "); for (i = 1; i < 5; i++) { oldLevel = 0; newLevel = loadLevelState(i); update(i, newLevel); } Serial.println("Ready to receive messages..."); } void loop() { // Process incoming messages (like config and light state from controller) gw.process(); hearir(); // check the ir } void incomingMessage(const MyMessage &message) { if (message.isAck()) { Serial.println("Got ack from gateway"); } if (message.type == V_LIGHT) { // Incoming on/off command sent from controller ("1" or "0") int lightState = message.getString()[0] == '1'; i = message.sensor; oldLevel = loadLevelState(i); newLevel = 0; if (lightState==1) { // Pick up last saved dimmer level from the eeprom newLevel = loadLevelState(i + 5); } } else if (message.type == V_DIMMER) { // Incoming dim-level command sent from controller (or ack message) oldLevel = loadLevelState(i); newLevel = atoi(message.getString(convBuffer)); i = message.sensor; // Save received dim value to eeprom (unless turned off) // Will be retrieved when an 'On' command comes in sendStatus(i, newLevel); if (newLevel != 0) { saveLevelState(i + 5, newLevel); } } update (i, newLevel); } // Make sure only to store/fetch values in the range 0-100 from eeprom int loadLevelState(byte pos) { return min(max(gw.loadState(pos),0),100); } void saveLevelState(byte pos, byte data) { gw.saveState(pos,min(max(data,0),100)); } // Get the right message name to send sensor info void sendStatus(int idx, int level) { switch (idx) { case 1: gw.send(RedStatus.set(level), false); break; case 2: gw.send(GreenStatus.set(level), false); break; case 3: gw.send(BlueStatus.set(level), false); break; case 4: gw.send(WhiteStatus.set(level), false); break; } } // Listen to IR sensor void hearir() { int c = remote.listen(1); remval = c; if (oldc != c && c >= 0) { remoteck(); } c = oldc; } void remoteck() { // toggle for (i = 1; i < 5; i++) { if (remval == toggleBtns[i]) { oldLevel = loadLevelState(i); newLevel = 0; if (oldLevel == 0) { newLevel = loadLevelState(i + 5); } update(i, newLevel); break; } } // up for (i = 1; i < 5; i++) { if (remval == upBtns[i]) { oldLevel = loadLevelState(i); if (oldLevel <= 90) { newLevel = oldLevel + 10; saveLevelState(i + 5, newLevel); update(i, newLevel); } break; } } // down for (i = 1; i < 5; i++) { if (remval == downBtns[i]) { oldLevel = loadLevelState(i); if (oldLevel >= 10) { newLevel = oldLevel - 10; if (newLevel != 0) { saveLevelState(i + 5, newLevel); } update (i, newLevel); } break; } } // all off if (remval == 6) { for (i = 1; i < 5; i++) { oldLevel = loadLevelState(i); newLevel = 0; update(i, newLevel); } } // all on if (remval == 12) { // returns to last saved values // could bring all up to 100%: newLevel = 100 for (i = 1; i < 5; i++) { oldLevel = loadLevelState(i); newLevel = loadLevelState(i + 5); update(i, newLevel); } } // RGB dim if (remval == 13) { for (i = 1; i < 4; i++) { oldLevel = loadLevelState(i); if (oldLevel >= 10) { newLevel = oldLevel - 10; if (newLevel != 0) { saveLevelState(i + 5, newLevel); } update(i, newLevel); } } } // RGB bright if (remval == 5) { for (i = 1; i < 4; i++) { oldLevel = loadLevelState(i); if (oldLevel <= 90) { newLevel = oldLevel + 10; saveLevelState(i + 5, newLevel); update(i, newLevel); } } } // status - displays current values in debug if (remval == 14) { Serial.println("Current levels:"); for (i = 1; i < 5; i++) { oldLevel = loadLevelState(i); Serial.print(color[i]); Serial.print(": "); Serial.print(oldLevel); Serial.println("%"); } } } void update(int idx, int level) { // Sends values to controller, outputs to pins, // saves to eeprom and outputs debug messages sendStatus(i, newLevel); fadeLEDToLevel(i, newLevel, FADE_DELAY); saveLevelState(i, newLevel); Serial.print("New light level received - "); Serial.print(color[i]); Serial.print(": "); Serial.print(newLevel); Serial.println("%"); } void fadeLEDToLevel( int LED, int toLevel, int wait ) { int delta = ( toLevel - oldLevel ) < 0 ? -1 : 1; while ( oldLevel != toLevel ) { oldLevel += delta; analogWrite( RGB_pins[LED], (int)(oldLevel / 100. * 255) ); delay( wait ); } }
-
RE: RGBW Controller kit
...and here's the correct link to the original kit! The Custom Geek
-
RGBW Controller kit
I've been looking around for a hardware solution for an RGBW LED strip controller, and came across this from The CustomGeek. It's a full kit of parts, and is based on an ATMEGA328P with an Arduino bootloader and sketch already loaded. The board uses 4 MOSFETs for the different LED channels, and has some interesting features:
- onboard RGB and white LEDs, which enable you to monitor the colours and levels of the LED strips
- serial interface, with TTL and RS232 level options, giving the ability to send serial commands (such as red50, to set red to 50%)
- an IR interface, using the Adafruit Mini Remote Controller (not included in the kit)
- an FTDI interface, to enable the Arduino to be reprogrammed (new sketches uploaded)
- unused analogue and digital pins brought out to a header, for easy external connection.
As such, I thought it should be possible to 'MySensorise' this, and add an NRF24L01+ radio.
I ordered the kit from the US (took about 2 weeks to arrive). I discovered that the board uses digital outputs 3, 9, 10 & 11, where the radio requires 9, 10 & 11. I got round this by swapping 5 & 11 on the board (cutting tracks, adding links), and changing CE & CS to 6 & 7 in the sketch. I've tried several of the RGB(W) sketches published on this site, and all work well! (I'm using Domoticz as controller.)
I made a few other minor mods to the board:
- I built a small 'daughterboard' consisting of the radio and AMS1117 (to provide 3.3V), and used different headers to enable this to be plugged in horizontally (see pics)
- I mounted the IR receiver on a header, so that I could use this externally from the board
- I changed the values of the resistors driving the onboard LEDs, as the latter were too bright.
I've included some pics below:
I've also developed a sketch, which I'll upload in another post.
-
RE: Dsiplaying dimmer percentage in Domoticz
Thanks again, @fifipil909 ! I do now recall the JSON section in the wiki stating this. I've also discovered that V_DIMMER is deprecated in MySensors 1.5 in favour of V_PERCENTAGE, but same behaviour here.
Shame you can't get 100%!
-
RE: Dsiplaying dimmer percentage in Domoticz
I'm seeing a strange effect with the same setup: if I drag the slider in Domoticz, it will display a percentage (e.g., 63%), but MySensors often displays a value (in Serial Monitor) a few points lower (e.g., 60%), and then Domoticz jumps down to that value. It also seems that the values are in intervals of 6 or 7% (e.g., 7% is the lowest I can get, and 100% goes down to 93%).
Any clues?
-
RE: Dsiplaying dimmer percentage in Domoticz
Thanks for the pointer @fifipil909 - I've now got it working successfully
-
Dsiplaying dimmer percentage in Domoticz
I'm using an RGBW LED controller with the MySensors RGB-3D sketch, and Domoticz as controller. I've set up the four LED channels as dimmers in Domoticz, and I can control the LEDs via the sliders and on / off switches.
Using the sliders displays percentages OK in Domoticz, and turning off a channel leaves the slider at the last position (but displays 'Off'). However, turn back on and the slider goes to 100% (and the switch displays 'On'), although the sketch - correctly - restores the last dimmer value (e.g., 60%).
Is there any way to get Domoticz to display the percentage (slider and value) when turning the switch back on?
-
RE: Graphing via RPi to website
I'm using a different approach using Google Charts, as outlined here.
I run Domoticz on a RPi, and I've written a Python script to get values from Domoticz using JSON calls every 10 minutes, and write these to a .csv file, creating a new file each day.
I then run a modified version of @stephenmhall's Python script, which creates an html file and calls Google Charts. One advantage of this approach is that you display the webpage in a local browser.
-
RE: RGBW Support?
Thanks for your help, @LastSamurai. I'm looking for an analogue one, where the whole strip is the same colour.
My next step is to decide on the hardware solution: existing specific board, or generic node + add-on board for MOSFETs (I don't see myself designing my own board - no experience).
-
RE: RGBW Support?
I'm looking to build a MySensors node connected to Domoticz, to control a RGBW strip, and I've been following this and other threads and sketches.
There's a number of things I'm not clear on:
-
how well supported are RGBW strips in Domoticz: should I be using V_RGBW or V_DIMMER (as @vil1driver suggests)?
-
should I be using an analogue or digital strip, and how do I tell them apart?
-
how are the strips configured - are they all common anode, with the cathode driven from the drain of an N-channel MOSFET (as @LastSamurai's schematic shows here.)
Thanks for your help.
-
-
RE: Text-Node as Temperature-Display
I built something similar here, but it just displays its 'own' values rather than getting them from Domoticz with V_TEXT.
-
RE: Temperature / humidity node with OLED display
I've since added a simple on/off switch, connected to D2, and changed the sketch to read the state of this pin and send a sleep/wake command to the SSD1306.
-
RE: Rechargeable Lithium Ion Sensor Custom PCB
Thanks for the clarification.
I've been using these:
-
RE: Rechargeable Lithium Ion Sensor Custom PCB
Looks really good.
Which 'flavour' of Pro Mini are you going with? I have ones with different pinouts. Also, I2C support would be good - for BMP180, SHT21, etc. (although can use prototyping area).
-
RE: Boiler control from MAX! Cube to Drayton Boiler via Raspberry Pi/Vera/Mysensors.
@stephenmhall Thanks for this, I found it really interesting, and whilst I'm not (yet) planning to control my CH in a similar way, I took the liberty of adapting your graphing.py script to graph a number of temperatures from my Domoticz controller (similar to your examples). I'm not using a database, but I'm writing values to a .csv file every 10 minutes, creating a new file every day. My version of the script then creates an html file, which produces a webpage like that below.
I've done a few tweaks, by following the Google Charts documentation. I prefer Google Charts, as you get 'live' tooltips and can combine several data series (as with plotly), but unlike plotly you create a local webpage rather than uploading / streaming.
(Sorry if this is a bit off-topic.)
-
RE: Plotting graphs with plot.ly service with luup scene using REST API
Like others, I've (regrettably) given up on plot.ly, and gone over to ThingSpeak.
I'm using the following Python code to send values from Domoticz:
thingURL = 'https://api.thingspeak.com/update?api_key=_YOUR_KEY_HERE' url = thingURL + "&field1=%s&field2=%s&field3=%s&field4=%s&field5=%s" \ % (inside, target, outside, lounge, heating) f = urllib2.urlopen(url) f.close()
-
RE: Temperature / humidity node with OLED display
I've used the following:
-
Ceech ATmega328p board w/ ESP8266 and NRF24l01+ socket LTC4067 lithium battery charger - here
-
HTU21D temperature and humidity sensor
-
SSD1306 1.3" I2C 128x64 display - here
-
micro USB breakout board
The sketch is included below (I've referenced the source of this in the comments at the beginning):
// Temp + humidity sensor // Using Ceech board // and SSD1306 128 x 64 OLED display. // This example is designed to fit Arduino Nano/Pro Mini // // SSD1306 text-only library taken from this thread: // https://forum.arduino.cc/index.php?topic=274880.0 #include <MySensor.h> #include <SPI.h> #include <Wire.h> // I2C #include <HTU21D.h> // temperature / humidity (i2c, HTU21D, SHT21) #include <SSD1306_text.h> // SSD1306 OLED display #include <Time.h> #define SKETCH_NAME "Temp + hum w. display" #define SKETCH_MAJOR_VER "1" #define SKETCH_MINOR_VER "1" #define TEMP_CHILD_ID 5 #define HUM_CHILD_ID 6 #define BATT_CHILD_ID 10 #define batteryVoltage_PIN A0 //analog input A0 on ATmega328 is battery voltage ( /2) #define LTC4067_CHRG_PIN A1 //analog input A1 on ATmega 328 is /CHRG signal from LTC4067 #define OLED_RST 4 SSD1306_text oled(OLED_RST); const float VccMin = 1.0*3.5; // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion. const float VccMax = 1.0*4.2; // Maximum expected Vcc level, in Volts. HTU21D SHT21; // Hum/Temp (SHT12) MySensor sensor_node(7,8); float lastTempSHT; // SHT temp/hum float lastHumSHT; float lastBattVoltage; int lastBattPct = 0; float VccReference = 3.3; boolean charge = false; boolean timeReceived = false; unsigned long lastUpdate=0, lastRequest=0; unsigned long SLEEP_TIME = 60000; // 60 sec sleep time between reads (seconds * 1000 milliseconds) MyMessage temperatureMsg(TEMP_CHILD_ID, V_TEMP); // SHT temp (deg C) MyMessage humidityMsg(HUM_CHILD_ID, V_HUM); // SHT hum (% rh) MyMessage batteryVoltageMsg(BATT_CHILD_ID, V_VOLTAGE); void setup() { analogReference(DEFAULT); // default external reference = 3.3v for Ceech board VccReference = 3.323 ; // measured Vcc input (on board LDO) sensor_node.begin(NULL, 21); // fixed node 21 Wire.begin(); // init I2C SHT21.begin(); // initialize temp/hum // Send the sketch version information to the gateway and Controller sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER); sensor_node.present(TEMP_CHILD_ID, S_TEMP); // SHT temp sensor_node.present(HUM_CHILD_ID, S_HUM); // SHT humidity sensor_node.present(BATT_CHILD_ID, S_POWER); // Battery parameters sensor_node.requestTime(receiveTime); // Initialize, optionally clear the screen oled.init(); oled.clear(); // clear screen oled.setTextSize(1,1); oled.setCursor(0); oled.print("NODE_2"); } void receiveTime(unsigned long controllerTime) { setTime(controllerTime); timeReceived = true; } void loop() { unsigned long now = millis(); sensor_node.process(); sensor_node.requestTime(receiveTime); lastRequest = now; Serial.print(hour()); printDigits(minute()); printDigits(second()); Serial.println(); oled.setTextSize(2,1); oled.setCursor(0,66); //oled.print(" "); if (hour() < 10) { oled.print("0"); } oled.print(hour()); oled.print(":"); if (minute() < 10) { oled.print("0"); } oled.print(minute()); sendTempHum(); Serial.println(); sendVoltage(); // Sleep until something happens with the sensor sensor_node.sleep(SLEEP_TIME); } void sendTempHum(void) { // SHT2x sensor // Temperature and Humidity float humidity = SHT21.readHumidity(); // send to MySensor network / only if change if (humidity != lastHumSHT && humidity != 0.00) { lastHumSHT = humidity; sensor_node.send(humidityMsg.set(humidity, 2)); // Send } float temperatureSHT = SHT21.readTemperature(); // send to MySensor network / only if change if (temperatureSHT != lastTempSHT && temperatureSHT != 0.00) { lastTempSHT = temperatureSHT; sensor_node.send(temperatureMsg.set(temperatureSHT, 2)); // Send } Serial.print("SHT21 temp: "); Serial.print(temperatureSHT); Serial.print(" SHT21 hum: "); Serial.print(humidity); oled.setCursor(2); oled.print("Temp: "); oled.print(temperatureSHT,1); oled.print("C"); oled.setCursor(4); oled.print("Hum : "); oled.print(humidity,0); oled.print("%"); } void sendVoltage(void) // battery values { // get Battery Voltage float batteryVoltage = ((float)analogRead(batteryVoltage_PIN)* VccReference/1024) * 2; // actual voltage is double Serial.print("Batt: "); Serial.print(batteryVoltage); Serial.print("V ; "); // send battery percentage for node int battPct = 1 ; if (batteryVoltage > VccMin){ battPct = 100.0*(batteryVoltage - VccMin)/(VccMax - VccMin); } charge = digitalRead(LTC4067_CHRG_PIN); sensor_node.send(batteryVoltageMsg.set(batteryVoltage, 3)); // Send (V) sensor_node.sendBatteryLevel(battPct); Serial.print("BattPct: "); Serial.print(battPct); Serial.println("% "); oled.setCursor(6); oled.print("Batt: "); oled.print(batteryVoltage,1); oled.print("V"); if (charge) oled.print("*"); else oled.print(" "); } void printDigits(int digits){ // utility function for digital clock display: prints preceding colon and leading 0 Serial.print(":"); if(digits < 10) Serial.print('0'); Serial.print(digits); }
It requires the attached libraries.
WRT the display: I've found that there are different drivers for different size displays, which require corresponding different libraries. There is a 0.96" version, which I originally used, which used the SSD1306 driver and library, whereas many of the 1.3" versions use the SH1106. All I know is that the 1.3" display I use worked straight away, with the original library - YMMV.
-
-
RE: Temperature / humidity node with OLED display
@Dwalt Currently, yes. I haven't done any measurements yet on current / discharge rate, but I can power it from USB and charge the battery at the same time. I may add a push button to turn on the display.
-
Temperature / humidity node with OLED display
I've just built this temperature / humidity node, with a 1.3" OLED display:
The OLED is a 128x64 I2C version, driven by an SSD1306 chip, and will display 8 lines of text - but as I'm short-sighted , I've used double-height text, showing time (from Domoticz), temperature, humidity and battery voltage.
The node uses a Ceech board, and is powered by a Samsung phone battery with a micro-USB connector (top left) to charge it. There is an HTU21D temperature / humidity sensor bottom left. Connectors have been judiciously bent (!), so that the base will fit on the box.
The sketch is based on Ceech's example sketch for the board, with the inclusion of a cut-down, text-only library for the SSD1306 (to save space).
-
RE: Breakout boards - a plea for consistency!
I'm not sure I understand - I was talking about mounting these on a stripboard, where all the connections are different:
-
Breakout boards - a plea for consistency!
I recently built a multi-sensor node, with 3 I2C breakout boards: HTU21D (temperature, humidity), BMP180 (barometric pressure), BH1750FVI (light level). These all had different pinouts (pins at bottom, left to right):
HTU21D: Vcc > GND > SDA > SCL
BMP180: 3.3V > SDA > SCL > GND > Vcc (3.6V - 6V)
BH1750FVI: ADDR (connect to GND) > SDA > SCL > GND > VccFor those of us using stripboard (rather than designed PCBs), it would be good to have a consistent standard! (Oh, and the Ceech board I use has Vcc > SDA > SCL > GND.)
-
RE: Interrupt, Perform a specific function, not the loop
@martinhjelmare In your code example, the sleep function needs a non-zero last parameter, in order to wake on timer.
So line 104 should read:
wake_cause = sensor_node.sleep(PRIMARY_BUTTON_PIN-2, CHANGE, SECONDARY_BUTTON_PIN-2, CHANGE, SLEEP_TIME);
where SLEEP_TIME is in milliseconds, e.g.,
unsigned long SLEEP_TIME = 60000; // 60 sec sleep time between reads (seconds * 1000 milliseconds)
Just tested this on the binary switch sketch.
-
RE: My own board (50mm x 30mm)
@GertSanders said:
Now I need to find a nice ventilated little box to protect them from dust.
This might work - it's well ventilated; width & depth OK, but don't know about height.
http://www.ebay.co.uk/itm/291147751395?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
-
RE: Multisensor node using Ceech board
@joaoabs Glad you got it working.
No, I didn't tune the pots.
I had similar problems with solar panels: battery didn't seem to be charging. Also, you're getting a high solar voltage (6.64V) on a sunny day, as I did. I was concerned, as the absolute max Vin for the LTC4067 - from the datasheet, if I remember correctly - is 6.2V.
I gave up using solar cells, and I'll just charge the battery from a USB charger when I need to.
-
RE: How can i detect 230V (pump active)?
Success! with 1.0uF across photodiode, although pot adjustment setting is quite sensitive. May try replacing photodiode with LDR.
Thanks!
-
RE: How can i detect 230V (pump active)?
I'm trying to detect mains voltage as suggested above, using a miniature mains neon indicator and photodiode sensor module (digital output):
(http://www.ebay.co.uk/itm/301337737695?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT)
(http://www.ebay.co.uk/itm/161785822980?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT)I'm using the MySensors Door / Windows / Button example sketch, however in serial monitor I'm getting rapidly alternating fail messages:
send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:0 send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:1 send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:0 send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:1 send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:0 send: 1-1-0-0 s=3,c=1,t=16,pt=2,l=2,st=fail:1
Is this because the input is changing at 50Hz? (it works OK on a battery-powered torch).
Is there anything I can do to overcome this?
-
New Raspberry Pi to NRF24l01+ Shield
@Ceech: I've just seen your Raspberry Pi to NRF24l01+ Shield on eBay here and I'm assuming that this can be used to implement a Domoticz controller and gateway, using the MySensors RPi port?
Can you publish the GPIO pin assignment for the NRF24L01, please - in particular, which pin is used for CE on a RPI 2?
-
RE: Multisensor node using Ceech board
Here's the code I've used - it's based on Ceech's sketch for the board, with the addition of code for the BH1750:
/* PROJECT: MySensors / LiON charger board PROGRAMMER: AWI DATE: 28 april 2015/ last update: 11 may 2015 / BH1750 added: 5 September 2015 FILE: MS_Solar_2.ino LICENSE: Public domain Hardware: Ceech - ATmega328p board w/ ESP8266 and NRF24l01+ socket LTC4067 lithium battery charger and MySensors 1.4 Temp & Humidity - HTU21 Barometer & Temp - BMP085 Light sensor - BH1750 On board EEPROM (I2C) On board Li-On charger with multiple V/A measurements Special: program with Arduino Pro 3.3V 8Mhz SUMMARY: Reads on-board sensors and send to gateway /controller Remarks: On board EEPROM and MOSFET not used in this sketch Fixed node-id */ #include <SPI.h> #include <MySensor.h> #include <Wire.h> // I2C #include <HTU21D.h> // temperature / humidity (i2c, HTU21D, SHT21) #include <Adafruit_BMP085.h> // barometer / temperature #include <BH1750.h> #define LTC4067_CHRG_PIN A1 //analog input A1 on ATmega 328 is /CHRG signal from LTC4067 #define batteryVoltage_PIN A0 //analog input A0 on ATmega328 is battery voltage ( /2) #define solarVoltage_PIN A2 //analog input A2 is solar cell voltage (/ 2) #define solarCurrent_PIN A6 //analog input A6 is input current ( I=V/Rclprog x 1000 ) #define batteryChargeCurrent_PIN A7 //analog input A7 is battery charge current ( I=V/Rprog x 1000 ) #define LTC4067_SUSPEND_PIN 9 //digital output D9 - drive it high to put LTC4067 in SUSPEND mode const float VccMin = 1.0*3.5; // Minimum expected Vcc level, in Volts. Example for 1 rechargeable lithium-ion. const float VccMax = 1.0*4.2; // Maximum expected Vcc level, in Volts. #define TEMPERATURE_CHILD_ID 2 #define TEMP_CHILD_ID 3 #define HUM_CHILD_ID 4 #define BARO_CHILD_ID 5 #define BATT_CHILD_ID 10 #define SOLAR_CHILD_ID 11 #define LIGHT_CHILD_ID 6 HTU21D SHT21; // Hum/Temp (SHT12) Adafruit_BMP085 bmp; // define baro/ temp meter BH1750 lightSensor; // define light sensor MySensor gw(7,8); // Ceech board, 3.3v (pin default 9,10) unsigned long SLEEP_TIME = 60000; // 60 sec sleep time between reads (seconds * 1000 milliseconds) float lastTempSHT; // SHT temp/hum float lastHumSHT; float lastTempBMP; float lastPresBMP; int altitude = 100; // 330 feet above sealevel float lastBattVoltage; float lastBattCurrent; float lastSolarVoltage; float lastSolarCurrent; int lastBattPct = 0; uint16_t lastLux; float VccReference = 3.3 ; // voltage reference for measurement, definitive init in setup MyMessage temperatureMsg(TEMP_CHILD_ID, V_TEMP); // SHT temp (deg C) MyMessage humidityMsg(HUM_CHILD_ID, V_HUM); // SHT hum (% rh) MyMessage pressureMsg(BARO_CHILD_ID, V_PRESSURE); // BMP pressure (hPa) MyMessage batteryVoltageMsg(BATT_CHILD_ID, V_VOLTAGE); // Battery voltage (V) MyMessage batteryCurrentMsg(BATT_CHILD_ID, V_CURRENT); // Battery current (A) MyMessage solarVoltageMsg(SOLAR_CHILD_ID, V_VOLTAGE); // Solar voltage (V) MyMessage solarCurrentMsg(SOLAR_CHILD_ID, V_CURRENT); // Solar current (A) MyMessage luxMsg(LIGHT_CHILD_ID, V_LIGHT_LEVEL); // Light sensor (lux) void setup() { gw.begin(NULL, 19); // fixed node 19 // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("AWI Dev THB/batt 19", "1.0"); gw.present(TEMP_CHILD_ID, S_TEMP); // SHT temp gw.present(HUM_CHILD_ID, S_HUM); // SHT humidity gw.present(BARO_CHILD_ID, S_BARO); // BMP pressure (temp not used here) gw.present(BATT_CHILD_ID, S_POWER); // Battery parameters gw.present(SOLAR_CHILD_ID, S_POWER); // Solar parameters gw.present(LIGHT_CHILD_ID, S_LIGHT_LEVEL); // Light sensor // use VCC (3.3V) reference analogReference(DEFAULT); // default external reference = 3.3v for Ceech board VccReference = 3.323 ; // measured Vcc input (on board LDO) pinMode(LTC4067_SUSPEND_PIN, OUTPUT); // suspend of Lion charger set digitalWrite(LTC4067_SUSPEND_PIN,LOW); // active (non suspend) at start Wire.begin(); // init I2C SHT21.begin(); // initialize temp/hum bmp.begin(); // bmp085 temp/ baro lightSensor.begin(); // light sensor } void loop() { sendTempHum(); Serial.println(); sendTempBaro(); Serial.println(); sendVoltage(); Serial.println(); sendLight(); Serial.println(); gw.sleep(SLEEP_TIME); } void sendTempHum(void) { // SHT2x sensor // Temperature and Humidity float humidity = SHT21.readHumidity(); // send to MySensor network / only if change if (humidity != lastHumSHT && humidity != 0.00) { lastHumSHT = humidity; gw.send(humidityMsg.set(humidity, 2)); // Send } float temperatureSHT = SHT21.readTemperature(); // send to MySensor network / only if change if (temperatureSHT != lastTempSHT && temperatureSHT != 0.00) { lastTempSHT = temperatureSHT; gw.send(temperatureMsg.set(temperatureSHT, 2)); // Send } Serial.print("SHT21 temp: "); Serial.print(temperatureSHT); Serial.print(" SHT21 hum: "); Serial.print(humidity); } void sendTempBaro(void) // Send temperature and barometer from baro sensor (temp1) { float temperature = bmp.readTemperature(); // send to MySensor network / only if change (not sent here) if (temperature != lastTempBMP) { lastTempBMP = temperature; //gw.send(temperatureMsg.set(temperature, 1)); // Send } float pressure = (float)bmp.readSealevelPressure(altitude)/100; // send to MySensor network / only if change if (pressure != lastPresBMP) { lastPresBMP = pressure; gw.send(pressureMsg.set(pressure, 1)); // Send } Serial.print("BMP180 temp: "); Serial.print(temperature); Serial.print(" BMP180 pressure: "); Serial.print(pressure); } void sendVoltage(void) // battery and charging values { // get Battery Voltage & charge current float batteryVoltage = ((float)analogRead(batteryVoltage_PIN)* VccReference/1024) * 2; // actual voltage is double Serial.print("Batt: "); Serial.print(batteryVoltage); Serial.print("V ; "); float batteryChargeCurrent = ((float)analogRead(batteryChargeCurrent_PIN) * VccReference/1024)/ 2.5 * 1000; // current(mA) = V/Rprog(kohm) Serial.print(batteryChargeCurrent); Serial.println("mA "); // get Solar Voltage & charge current float solarVoltage = ((float)analogRead(solarVoltage_PIN)/1024 * VccReference) * 2 ; // actual voltage is double Serial.print("Solar: "); Serial.print(solarVoltage); Serial.print("V ; "); // get Solar Current float solarCurrent = ((float)analogRead(solarCurrent_PIN)/1024 * VccReference)/ 2.5 * 1000; // current(mA) = V/Rclprog(kohm) Serial.print(solarCurrent); Serial.print(" mA; charge: "); Serial.println(digitalRead(LTC4067_CHRG_PIN)?"No":"Yes"); // send battery percentage for node int battPct = 1 ; if (batteryVoltage > VccMin){ battPct = 100.0*(batteryVoltage - VccMin)/(VccMax - VccMin); } Serial.print("BattPct: "); Serial.print(battPct); Serial.println("% "); gw.send(batteryVoltageMsg.set(batteryVoltage, 3)); // Send (V) gw.send(batteryCurrentMsg.set(batteryChargeCurrent, 6)); // Send (mA) gw.send(solarVoltageMsg.set(solarVoltage, 3)); // Send (V) gw.send(solarCurrentMsg.set(solarCurrent, 6)); // Send (mA) gw.sendBatteryLevel(battPct); } void sendLight(void) // Send light level - BH1750 { uint16_t lux = lightSensor.readLightLevel(); if (lux != lastLux) { gw.send(luxMsg.set(lux)); // Send lastLux = lux; } Serial.print("BH1750 lux: "); Serial.print(lux); } /* Ceech board specifics for reference: It provides power for the circuit and charges the backup single-cell lithium battery while greatly extends battery life. You can monitor the voltages and currents. It has suspend mode, which reduces current consumption to around 40ΞA. The power source is a small, 5V solar cell. Connections: analog input A1 on ATmega 328 is /CHRG signal from LTC4067 (indicates fully charged) analog input A0 on ATmega328 is battery voltage analog input A2 is solar cell voltage analog input A6 is input current ( I=V/Rclprog x 1000 ) analog input A7 is battery charge current ( I=V/Rprog x 1000 ) digital output D9 - drive it high to put LTC4067 in SUSPEND mode All the voltages on analog inputs can be read with an analogRead() command in the Arduino IDE sketch. Those on inputs A0 an A2 represent direct values of the measured voltages divided by 2. The voltages on analog inputs A6 and A7 can be translated to currents. For example: Let us say that the voltage on A7 is 0.12V. And the trimmer pot on PROG pin is set to 2.5kOhm. This means that the current into the battery equals to 0.12V/2500ohm x 1000, which is 48mA. voltmeters on both battery and solar cell connections They are connected to analog inputs A0 and A2 on the ATmega328p. The voltage dividers resistors are equal, so the measured voltage is double the shown voltage. NRF24l01+ socket with CE and CSN pins connected to digital pins 7 and 8 ( you use RF24 radio(7, 8); in Arduino code). There is a 4.7uF capacitor connected across Vin and GND of the port */
-
RE: How can i detect 230V (pump active)?
What's a 'small signal lamp', and how much power does it draw?
I'm looking for a similar solution - I want to monitor my central heating and hot water system. I've got a UK 'Y-plan' system, with a mid-position valve. One wire to the valve is energised (i.e., 230V) when heating is on, while another is energised when hot water is off.
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
That's the code change I made (makes the 'if' redundant).
I've also changed the tty name (to /dev/ttyUSB40 - which is what I've declared to Domoticz) in this file and in Makefile.
BTW: Very impressed with OSH Park - got the PCBs here in UK (from US) 13 days after ordering!
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
All now working OK - many thanks!
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
Hello @GertSanders, for the time being I've got the gateway working with CE connected to pin 15, having carried out some 'surgery' to the board!
I've found this code in PiGatewaySerial.cpp (line 198 onwards):
/* create MySensors Gateway object */
#ifdef __PI_BPLUS
gw = new MyGateway(RPI_BPLUS_GPIO_J8_15, RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ, 1);
#else
gw = new MyGateway(RPI_V2_GPIO_P1_22, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ, 1);
#endifIs this the 'offending' code?
-
RE: Multisensor node using Ceech board
@Dwalt I cut a slot in one end of the box; I intend to use it outdoors, mounted vertically, so that the slot is at the bottom.
The button is a reset button, wired to the RESET connection on the Ceech board. I made a small hole in the lid (covered with Sellotape!), so that I can insert a pin / paper clip to press it. -
Multisensor node using Ceech board
Here are some pics of my multisensor node, using the Ceech board with lithium battery charger. The stripboard houses - from left to right - a BMP180, HTU21D and BH1750FVI. As you can see, I've soldered radio and connections directly to the board, to reduce height in order to fit the box.
The box is the same as the one shown here:
(http://www.ebay.com/itm/85x58x33mm-Waterproof-Cover-Clear-Plastic-Electronic-Project-Box-Enclosure-CASE-/281390875149?hash=item418434020d)(but purchased from UK eBay website).
I had to shave the board down by about 1-2mm on one edge, to fit the box - sorry, Ceech!
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
Cracked it! I'm using an RPi 2, and cat /proc/cpuinfo gives a01041 as hardware version. According to GitHub readme, CE needs to go to pin 15, not 22.
Now working with radio connected directly, but will now need to connect a jumper wire from the adaptor board.
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
Thanks, Gert. I've checked all my soldering (continuity from header to header), the jumper is soldered for 5V, and I'm getting 3V3 across the supply pins of the radio. Board is sitting between 17/18 & 23/24.
I'm still only getting the above 2 lines in the log, i.e., no devices.
I'll try connecting the radio direct to the GPIO later today. -
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
Hi @GertSanders, I've received the PCB, built the adaptor and the software as per the MySensors Raspberry Port GitHub. I've created a symlink to /dev/ttyMySensorsGateway (/dev/ttyUSB40), which Domoticz, and I see the following in the Domoticz log:
2015-09-29 17:48:40.503 MySensors: Using serial port: /dev/ttyUSB40
2015-09-29 17:48:40.503 MySensors: Gateway Ready...However, I can't see any of the devices on my node - any ideas?
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
@GertSanders Thanks for the extra info - that was very helpful.
-
RE: Domoticz as controller **and** a gateway for MySensor nodes running on a Raspberry Pi 2
@GertSanders This looks really good, and will greatly simplify my set-up. I'm going to order the board from OSH Park - is there a list of components / instructions (I notice the board has solder jumpers)?
-
RE: Sensor board w/ liPo charger and fuel gauge +BMP180 +HTU21
@Ceech I guess I'm concerned that the solar cell voltage Vin might exceed 7V - which the datasheet says is the absolute max. (and the max. overvoltage threshold Vovth is 6.2V). I've been getting >6.5V, with the solar cell not pointing directly at the sun (i.e., not due south / azimuth). I'll take some measurements with the solar cell disconnected. I can see that it would be very difficult to interrupt the IN connection (pin 12); is there another way of limiting the solar cell voltage?
-
RE: Sensor board w/ liPo charger and fuel gauge +BMP180 +HTU21
@Ceech Thanks, I'll give this a try; I need to make some hardware mods first - I'm thinking of including a MOSFET in series with IN, as per datasheet.
-
RE: Sensor board w/ liPo charger and fuel gauge +BMP180 +HTU21
I've just built a version of this, using the solar cell from the Solar Motion Light identified in this project: Solar Powered Mini-Weather Station. I'm using Domoticz as the controller.
I'm trying to understand what the solar and battery currents represent (I had to scale these by 1000, as Domoticz will only display currents in amps). Also, at what battery voltage level will the battery start to charge? and what level of solar voltage is required? I'm also concerned that the solar cell voltage can exceed 6V in bright sunlight - is there a need for overvoltage protection on the LTC4067?
(I'll post details and pics in My Projects shortly.)