sensors in boxes
-
Sure no problem.. It's the stock code for the dallas temperature sensor with the simple addition for the battery monitoring.
oh and just as an update on that.. still haven't replaced the batteries in the sensors and they are still reporting 82%, which is a run time of over 4 months now.
// Example sketch showing how to send in OneWire temperature readings #include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); MySensor gw; float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); MyMessage msgvolt(1,V_VOLTAGE); int BATTERY_SENSE_PIN = A0; int oldBatteryPcnt = 0; void setup() { analogReference(INTERNAL); // Startup OneWire sensors.begin(); // Startup and initialize MySensors library. Set callback for incoming messages. gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Temperature Sensor", "1.0"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { gw.present(i, S_TEMP); } } void loop() { // Process incoming messages (like config from server) gw.process(); // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // Battery Monitoring int sensorValue = analogRead(BATTERY_SENSE_PIN); float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { gw.send(msgvolt.set(batteryPcnt,1)); oldBatteryPcnt = batteryPcnt; } // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature gw.send(msg.setSensor(i).set(temperature,1)); lastTemperature[i]=temperature; } } gw.sleep(SLEEP_TIME); } -
Sure no problem.. It's the stock code for the dallas temperature sensor with the simple addition for the battery monitoring.
oh and just as an update on that.. still haven't replaced the batteries in the sensors and they are still reporting 82%, which is a run time of over 4 months now.
// Example sketch showing how to send in OneWire temperature readings #include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); MySensor gw; float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); MyMessage msgvolt(1,V_VOLTAGE); int BATTERY_SENSE_PIN = A0; int oldBatteryPcnt = 0; void setup() { analogReference(INTERNAL); // Startup OneWire sensors.begin(); // Startup and initialize MySensors library. Set callback for incoming messages. gw.begin(); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("Temperature Sensor", "1.0"); // Fetch the number of attached temperature sensors numSensors = sensors.getDeviceCount(); // Present all sensors to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { gw.present(i, S_TEMP); } } void loop() { // Process incoming messages (like config from server) gw.process(); // Fetch temperatures from Dallas sensors sensors.requestTemperatures(); // Battery Monitoring int sensorValue = analogRead(BATTERY_SENSE_PIN); float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { gw.send(msgvolt.set(batteryPcnt,1)); oldBatteryPcnt = batteryPcnt; } // Read temperatures and send them to controller for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) { // Fetch and round temperature to one decimal float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.; // Only send data if temperature has changed and no error if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature gw.send(msg.setSensor(i).set(temperature,1)); lastTemperature[i]=temperature; } } gw.sleep(SLEEP_TIME); }@GuyP what kind of chip is the big one? Does not look like nano or pro mini. Terrific run time so must be efficient.
-
It's an ATMEGA328P, which is the Arduino processor, I buy them in bulk from China, write the boot loader and flash the code onto them using an uno board.
@GuyP Cool! these are really cheap and they save on cutting the LED and voltage regulator.... it looks like they are even more economical in energy then the modified (no LED no voltage reg) pro mini. Can you detail for a complete idiot the bootloader and flash thing?
-
I'm running everything at 3 volts from the 2 AAA batteries. The box is 3D printed and integrates the battery box. I'm not using any screws, just slide rails for the PCB , top and back.
I have two board types now. One with just the single Dallas temp sensor on it, which turns out to be what I need most of.

I also created another board which has three Connectors, JP1-3, which allows to additional Dallas Temp sensors. I have these in locations where I can run wires more easily, like my loft spaces.

I'm etching everything myself. Very simple really. I'm using the print on to glossy paper and transfer onto copper board, using a laminator, method. Works really well. As these boards are small I tend to etch a few at a time onto a single copper board and then cut the board at the end.
-
It's an ATMEGA328P, which is the Arduino processor, I buy them in bulk from China, write the boot loader and flash the code onto them using an uno board.
@GuyP Do you have a favourite seller for those mega328 DIP parts? Mostly when I've looked on eBay the clone Arduino Mini's come in cheaper than a DIP package mega328 IC. I also would prefer to use a design that utilises the mega328 DIP directly rather than an Arduino Mini if I could. Cost per node is very important to me to enable affordable expansion of my network. Thanks.
-
@GuyP Do you have a favourite seller for those mega328 DIP parts? Mostly when I've looked on eBay the clone Arduino Mini's come in cheaper than a DIP package mega328 IC. I also would prefer to use a design that utilises the mega328 DIP directly rather than an Arduino Mini if I could. Cost per node is very important to me to enable affordable expansion of my network. Thanks.
@hawk_2050 look here
That is much cheaper.... 1.4$/node
-
@hawk_2050 look here
That is much cheaper.... 1.4$/node
@hawk_2050 I buy them from banggood.com where they discount for quantity so I'm usually paying about £1.66 a chip and free delivery.
However looking at @Moshe-Livne he's found a cheaper place.. so I think I'll be using them from now on :)
-
@GuyP Cool! these are really cheap and they save on cutting the LED and voltage regulator.... it looks like they are even more economical in energy then the modified (no LED no voltage reg) pro mini. Can you detail for a complete idiot the bootloader and flash thing?
@Moshe-Livne the boot loader..
https://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader
I use this method to write the boot loaders using an uno..
https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
works great. I use a Zero insertion socket for the chip and rattle through the chips in a seconds.
-
@GuyP Can you post the pdf images of the boards, I want to etch some I like the use of 328P chip, The only problem the png file is scaled wrong too large.
@DrJeff Sure no problem..
I've also now built a "Repeater Board", this board can either act as a repeater, and be powered by USB mini, or battery (Best not on battery when in repeater mode). It also has the expansion to add multiple Dallas Temperature sensors. JP1-3 sensors can be daisy chained up to around 16 in total. I have these boards in loft spaces, and garage where I want to watch temperature in lots of locations and I don't mind a few wires.

Let me know if those work out better...
-
@Moshe-Livne the boot loader..
https://www.arduino.cc/en/Hacking/Bootloader?from=Tutorial.Bootloader
I use this method to write the boot loaders using an uno..
https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
works great. I use a Zero insertion socket for the chip and rattle through the chips in a seconds.
@GuyP That looks pretty simple... what boot loader do you write? do you really remove the processor from the uno or did you make a dedicated one? do you use the minimal breadboard version? This system also has the upside of not having to deal with the irritating counterfeit or ch340 ftdi chips, so bonus points...
-
@DrJeff Sure no problem..
I've also now built a "Repeater Board", this board can either act as a repeater, and be powered by USB mini, or battery (Best not on battery when in repeater mode). It also has the expansion to add multiple Dallas Temperature sensors. JP1-3 sensors can be daisy chained up to around 16 in total. I have these boards in loft spaces, and garage where I want to watch temperature in lots of locations and I don't mind a few wires.

Let me know if those work out better...
-
@GuyP That looks pretty simple... what boot loader do you write? do you really remove the processor from the uno or did you make a dedicated one? do you use the minimal breadboard version? This system also has the upside of not having to deal with the irritating counterfeit or ch340 ftdi chips, so bonus points...
@Moshe-Livne When writing the boot loader you need to keep the uno chip in the board.
Once you've written all the board loaders, then you can pull the chip from uno and replace it with all the new ones to write the temperature sensor codes.
-
@GuyP Cool thanks, Time to etch some boards, have you used this method/setup for other nodes? Just trying to get some ideas :grinning:
@DrJeff At the moment just temperature sensors.. however the plan is to also control my heating system around the house.
I will put putting controllers on all the radiators around the house, and replacing the controller in the house with simple radio buttons which feed back to openhab for manual over ride.
Just not had time yet! :(
-
@DrJeff At the moment just temperature sensors.. however the plan is to also control my heating system around the house.
I will put putting controllers on all the radiators around the house, and replacing the controller in the house with simple radio buttons which feed back to openhab for manual over ride.
Just not had time yet! :(
-
@GuyP Yes we always got to deal with real life! On the board I assume the red lines are wires due to the single sided board?
-
I'm running everything at 3 volts from the 2 AAA batteries. The box is 3D printed and integrates the battery box. I'm not using any screws, just slide rails for the PCB , top and back.
I have two board types now. One with just the single Dallas temp sensor on it, which turns out to be what I need most of.

I also created another board which has three Connectors, JP1-3, which allows to additional Dallas Temp sensors. I have these in locations where I can run wires more easily, like my loft spaces.

I'm etching everything myself. Very simple really. I'm using the print on to glossy paper and transfer onto copper board, using a laminator, method. Works really well. As these boards are small I tend to etch a few at a time onto a single copper board and then cut the board at the end.
@GuyP can you please export it in brd or dxf?
-