Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. sensors in boxes
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

sensors in boxes

Scheduled Pinned Locked Moved My Project
57 Posts 11 Posters 34.4k Views 16 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • GuyPG Offline
    GuyPG Offline
    GuyP
    wrote on last edited by GuyP
    #1

    I think I must have read almost every page on this site when I discovered it. I really loved this idea. For ages I've wanted to monitor and interact with my surroundings via some home automation solution, but all the commercial solutions are really expensive and limited. MySenors and OpenHAB really give me the customisation I want.

    The only thing missing was putting everything together. I'm working on that. But first I needed to create my sensors, as small/cheap as possible and battery powered.

    Here's my first pass at building the temperature sensor, in a 3D printed box which also houses the battery compartment.

    i2iurp.jpg

    The circuit board (Single Sides Etch) slides in on groves in the walls. I added the battery monitoring to the Arduino as I really need to know if/when the batteries are going flat. That's all pushed back to openHAB which I can then create a rule to watch for battery low, however so far the batteries seem that they will last for ever!

    The contacts on the battery box are small flat metal. Aluminium between the batteries, and Copper for the terminals. I used copper as I could more easily solder to it.

    Making it very easy to assemble.

    1 Reply Last reply
    8
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi, great project!
      Would you mind sharing a bit more about your circuit? Are you using step-up regulators to power the atmega? Did you etch the PCB yourself or ordered it somewhere?
      I was thinking of a similar project. My idea is to add 3.5mm female jacks to easily add external sensors, e.g external temperature probes, pulse watt counter, etc, and maybe a latching on off switch (but then again, who wants to power off their sensors).

      1 Reply Last reply
      0
      • GuyPG Offline
        GuyPG Offline
        GuyP
        wrote on last edited by
        #3

        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.

        TempSensorBase.stl

        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.
        tempSensor.png

        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.

        tempSensor+.png

        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.

        DrJeffD Moshe LivneM 2 Replies Last reply
        0
        • 5546dug5 Offline
          5546dug5 Offline
          5546dug
          wrote on last edited by
          #4

          @GuyP Great looking project! How is your battery level usage so far?

          1 Reply Last reply
          0
          • GuyPG Offline
            GuyPG Offline
            GuyP
            wrote on last edited by
            #5

            Project has now been running for over a month. The study is the Longest running sensor at closer to 2 months.

            As you can see the batteries are still in very good shape... Also I'm still polling every 30seconds for the temp. So if I was worried about the battery I could reduce the poll to say once every 5 minutes and not lose anything in resolution.

            batteryLevels.png

            1 Reply Last reply
            0
            • 5546dug5 Offline
              5546dug5 Offline
              5546dug
              wrote on last edited by
              #6

              @GuyP would you care to share your code for this project?

              1 Reply Last reply
              0
              • GuyPG Offline
                GuyPG Offline
                GuyP
                wrote on last edited by GuyP
                #7

                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.

                BatteryStatus.tiff

                
                // 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);
                }
                
                
                
                
                Moshe LivneM 1 Reply Last reply
                0
                • GuyPG GuyP

                  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.

                  BatteryStatus.tiff

                  
                  // 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);
                  }
                  
                  
                  
                  
                  Moshe LivneM Offline
                  Moshe LivneM Offline
                  Moshe Livne
                  Hero Member
                  wrote on last edited by
                  #8

                  @GuyP what kind of chip is the big one? Does not look like nano or pro mini. Terrific run time so must be efficient.

                  1 Reply Last reply
                  0
                  • GuyPG Offline
                    GuyPG Offline
                    GuyP
                    wrote on last edited by
                    #9

                    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.

                    Moshe LivneM H 2 Replies Last reply
                    0
                    • GuyPG GuyP

                      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.

                      Moshe LivneM Offline
                      Moshe LivneM Offline
                      Moshe Livne
                      Hero Member
                      wrote on last edited by
                      #10

                      @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?

                      GuyPG 1 Reply Last reply
                      0
                      • GuyPG GuyP

                        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.

                        TempSensorBase.stl

                        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.
                        tempSensor.png

                        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.

                        tempSensor+.png

                        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.

                        DrJeffD Offline
                        DrJeffD Offline
                        DrJeff
                        wrote on last edited by
                        #11

                        @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.

                        GuyPG 1 Reply Last reply
                        0
                        • GuyPG GuyP

                          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.

                          H Offline
                          H Offline
                          hawk_2050
                          wrote on last edited by
                          #12

                          @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.

                          Moshe LivneM 1 Reply Last reply
                          0
                          • H hawk_2050

                            @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.

                            Moshe LivneM Offline
                            Moshe LivneM Offline
                            Moshe Livne
                            Hero Member
                            wrote on last edited by
                            #13

                            @hawk_2050 look here

                            That is much cheaper.... 1.4$/node

                            GuyPG 1 Reply Last reply
                            0
                            • Moshe LivneM Moshe Livne

                              @hawk_2050 look here

                              That is much cheaper.... 1.4$/node

                              GuyPG Offline
                              GuyPG Offline
                              GuyP
                              wrote on last edited by
                              #14

                              @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 :)

                              1 Reply Last reply
                              0
                              • Moshe LivneM Moshe Livne

                                @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?

                                GuyPG Offline
                                GuyPG Offline
                                GuyP
                                wrote on last edited by
                                #15

                                @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.

                                Moshe LivneM 1 Reply Last reply
                                0
                                • DrJeffD DrJeff

                                  @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.

                                  GuyPG Offline
                                  GuyPG Offline
                                  GuyP
                                  wrote on last edited by
                                  #16

                                  @DrJeff Sure no problem..

                                  TempSensor.pdf

                                  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.

                                  RepeaterBoard.png

                                  TempSensorRepeater.pdf

                                  Let me know if those work out better...

                                  DrJeffD 1 Reply Last reply
                                  0
                                  • GuyPG GuyP

                                    @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.

                                    Moshe LivneM Offline
                                    Moshe LivneM Offline
                                    Moshe Livne
                                    Hero Member
                                    wrote on last edited by
                                    #17

                                    @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...

                                    GuyPG 1 Reply Last reply
                                    0
                                    • GuyPG GuyP

                                      @DrJeff Sure no problem..

                                      TempSensor.pdf

                                      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.

                                      RepeaterBoard.png

                                      TempSensorRepeater.pdf

                                      Let me know if those work out better...

                                      DrJeffD Offline
                                      DrJeffD Offline
                                      DrJeff
                                      wrote on last edited by
                                      #18

                                      @GuyP Cool thanks, Time to etch some boards, have you used this method/setup for other nodes? Just trying to get some ideas :grinning:

                                      GuyPG 1 Reply Last reply
                                      0
                                      • Moshe LivneM Moshe Livne

                                        @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...

                                        GuyPG Offline
                                        GuyPG Offline
                                        GuyP
                                        wrote on last edited by
                                        #19

                                        @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.

                                        1 Reply Last reply
                                        0
                                        • DrJeffD DrJeff

                                          @GuyP Cool thanks, Time to etch some boards, have you used this method/setup for other nodes? Just trying to get some ideas :grinning:

                                          GuyPG Offline
                                          GuyPG Offline
                                          GuyP
                                          wrote on last edited by
                                          #20

                                          @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! :(

                                          DrJeffD 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          17

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular