Using 6 sensors at once on an Arduino

Hi

As a teacher (and moderate Arduino hobbyist), I'm building a weather station as a science project for my class. I wanted all of them to be involved maximally, which is why I use 6 sensors at once. While they are still working on the theoretical part, I'm testing all the sensors and the code. Each group will be tweaking their own sensor. This is a list of the sensors I use:

  • DHT 22 humidity and temperature sensor
  • NTC 10k thermistor
  • BMP280 air pressure an temperature sensor
  • Velleman VMA303 rain sensor
  • standard LDR from my starter kit
  • Adafruit anemometer sensor

All of them work (the BMP280 is the most tricky) and I have just enough inputs, but I'm worried about bringing it all together. Furthermore, I will use an Ethernet shield to connect the Arduino to a web server (which I've tested too) and which I think draws current. While the anemometer works at the Vin voltage (9V), all other sensors will be connected to 5V. Even with the specs at hand, it is almost impossible to predict how much current they will draw. Also, can the Arduino handle all this data? Fortunately, it doesn't have to be fast. Measuring four times an hour is sufficient.

So my questions are: should I connect my sensors to an extra 5V power source to prevent damage to my Arduino? And should I consider buying an Arduino Mega 2560 (which can handle more data) for this project? At this point, I'm using my own Arduino UNO.

Thanks a lot for your suggestions :slight_smile:

Jan

An external 5v power supply won't be expensive and it provides reassurance.

You have given us no basis for commenting on the quantity of data - that depends on what size values are gathered from the sensors, how many readings per second you want to make and how long you want to store the data on the Arduino.

My guess (but its no more than that) is that an Uno wil be sufficient if it has sufficient I/O pins because I would not expect you would need frequent sensor readings for weather data.

...R

Why only just enough pins? Doesn't look like more than a handful needed.

Whether it can handle the amount of data also depends on what you want to do with it.

Hi, Robin2 and wvmarle

Robin2:
An external 5v power supply won't be expensive and it provides reassurance.

You're right: using a, external regulated 5V power supply should solve any power problems. It might be a dumb question, but just to be sure: in that case all black ground wires are to be connected, right?

Robin2:
My guess (but its no more than that) is that an Uno wil be sufficient if it has sufficient I/O pins because I would not expect you would need frequent sensor readings for weather data.

That is indeed the case. Collecting data four times an hour is more than sufficient. Data will be sent to a web server (via GET request, in a php log file, I have someone to help me with that kind of stuff) where a time stamp should be added. About the amount of data: 5 floats and 1 integer would have to be read at approximately the same time (although a delay of more than a few seconds here and there would be no problem) and sent to the server. The sketch needs to include a few libraries: dht.h, wire.h, Adafruit_Sensor.h, SPI.h, Wire.h and Adafruit_BP280.h. Maybe I should have waited until I completed the sketch, but I have to decide whether or not to buy an Arduino Mega now, hence my question. I guess since we have the budget, I should go for it. Concerning the package to be sent to the web server, a float takes only 4 bytes, right? That shouldn't be a problem.

wvmarle:
Why only just enough pins? Doesn't look like more than a handful needed.

wvmarle, I meant the analog inputs A0-A5. Apart from the DHT sensor (humidity), all inputs are analog and the BMP280 (air pressure) uses two. So I need all six analog inputs.

Thanks for your opinions. Once I get to bring everything together, I might run into problems with the sketch. Until then, I should be ok :slight_smile:

Jan

You seem to have 3 temperature sensors. Why is that? I get that you need the DHT22 for humidity and the bmp280 for pressure, but they both measure temperature. So why the thermistor as well? Also, if you swap to the bme280, that one sensor will measure temp, humidity and pressure, so you won't need the DHT22 or the thermistor.

You should understand that the bmp280 is not using two analog inputs. It is using the i2c bus, which consists of two pins: SDA and SCL. It so happens that on Uno (and some other Arduino) these pins are shared with two of the analog pins, and you can't use them for both purposes in the same circuit. But on other Arduino they are not shared. I know that this fact makes no practical difference if you are using an Uno, you still lose the use of two analog pins, but it's an important distinction.

The i2c bus is very clever and useful. Many sensors can be connected to those same two pins and yet still read independantly. But only sensors which are i2c compatible. The i2c bus can also be used to add more analog inputs, or more digital inputs and outputs.

OK, let me go through your list in more detail.

jmuylle:

  • DHT 22 humidity and temperature sensor
  • NTC 10k thermistor
  • BMP280 air pressure an temperature sensor
  • Velleman VMA303 rain sensor
  • standard LDR from my starter kit
  • Adafruit anemometer sensor

DHT22: indeed a digital one. But the BME280 is much better for humidity, so swapping out the BMP280 for this one makes that sensor redundant.

NTC: that's for temperature, but the BMP/E280 also measures temperature, making it redundant.

BMP280: that's a digital sensor, connecting to the I2C pins, which indeed share two of the analog inputs.

The VMA280 (I had to look that one up) is not a rain sensor, and I don't see how it can reliably be used as such. At best it gives you a "there's rain, or there has been in the time it takes for the sensor to dry up" kind of reading.
Normal rain sensors - those that actually detect rain and how much has fallen - are usually a tipping bucket type of sensor, sending pulses. That'd be a digital input.

LDR: analog indeed, and very inaccurate to measure light levels. Better use a digital sensor that's connecting to the I2C bus, such as the TSL2591. Much easier to read, too.

Anemometer: I suppose you mean this one? Indeed a voltage output. I expected another pulse output, where the time between pulses gives the speed.

Now to read both the anemometer and the NTC and LDR reliably, that's a problem. The NTC and LDR are ratiometric in their output, so you should read them using Vcc as reference, the default. The anemometer however is absolute, so you need a fixed reference voltage like the built-in 1.1V one (you'd need a voltage divider in that case on the anemometer output). Otherwise the measurement is as stable as your 5V supply.

Maybe switching reference in code works? I never tried.

There are ways to overcome these issues - but it depends on how accurate you need it to be.

For the web server connection: if you use an external ADC (like the ADS1115) and an ESP8266 as controller (use a NodeMCU or WeMOS mini board) you can read all sensors and do your network uploads (it has built-in WiFi and http server/client) from one controller.

jmuylle:
You're right: using a, external regulated 5V power supply should solve any power problems. It might be a dumb question, but just to be sure: in that case all black ground wires are to be connected, right?

All ground wires have to be connected, regardless of the colour.
By convention often the ground is indeed black, but sometimes blue, and sometimes yet another colour. So while it's OK to expect black to be the ground, it's wrong to just assume it is the case without checking against the manuals.

Thanks for your answers. I will consider them all in the next few days. I feel this project might have been too ambitious too start with. But someone told me there are no problems, only challenges... About the redundancy though, you are right of course, but this is because I have 6 groups of students, each with their specific sensor to tweak. I don't even know which temperature sensor will give the best results. But i'll get back to you on this.

jmuylle:
I don't even know which temperature sensor will give the best results.

My money is on the BMP280 - by far the easiest. Plug and play.

The NTC should be able to beat it, though. Can have very high accuracy but the totally non-linear response makes it hard to get the numbers right (a lookup table with interpolation works great). By far the hardest of your sensors to get right.

@wvmarle: Just a quick question before I buy anything else: if I were to connect a decent light sensor (TSL2591) using the I2C bus, I can use the same connections as the BMP280, right? Do I need to address it differently in the sketch then, or how does this distinction work? thx :wink:

And, just to make this clear: this project is merely educational. If the accuracy of our measurements isn't ideal, there is room to learn. This is why I like 'simple' devices like the LDR and NTC because they already know about circuits and types of resistors from my classes. I would also like them to monitor several factors the oldfashioned way, just to compare to the electronic data: a pluviometer (does that word exist in English?), a wind sock, a glass thermometer...

I2C is a bus, meant to have multiple devices connected. Each device indeed should have a unique address on the bus.

jmuylle:
. This is a list of the sensors I use:

And should I consider buying an Arduino Mega 2560 (which can handle more data) for this project? At this point, I'm using my own Arduino UNO.

Very likely, but probably not until after you have exhausted the Uno you already have.

The sensors are barely relevant to the discussion, same goes for the frequency of collection. What matters is what you intend to do with the data, about which you say virtually nothing, and even what you do was actually just in passing.

So, do you intend to record the data?
Do you intend to display it locally?
Do you intend to have a local clock?
These, and the comment about webserver, all involve memory, and you are likely to run out of that before you run out of pins.

This project is not necessarily too ambitious for you, as you are able to address it is small stages - just like everybody else does, but it is a mistake to like NTCs because they are "simple", and that might apply to all analogue devices.

I say "very likely" only in terms of comparison with a Uno, because you have brought WiFi in to the game. So note

You may find that a Node-MCU or and ESP32 can do the whole thing - particularly if you cull redundant sensors.

All ESP8266 devices have their own intelligence - and memory. This means they can share the workload in data collection, and I believe that approach probably means a Mega is unnecessary.

ESP8266 and Arduino speak the same language so, while you may find a Node-MCU doing all the real work with Uno just doing the local peripherals, developing on the Uno you already have will not be wasted.

Nick_Pyner:
So, do you intend to record the data?
Do you intend to display it locally?
Do you intend to have a local clock?

Well Nick: As a test, I tried the Ethernet shield to display the values from the DHT as a web page with a webserver sketch, which was easy. But I would like to try and use it as a web client. A log file in php could be created on the server including a time stamp (not generated by the Arduino... I think). Since I'm not an IT'er I'm going to meet with a friend who should be able to do this. So please don't ask me about SQL's and stuff, because it's all Chinese to me. Displaying the values on a web page might be a perfect showcase for our open school day though... (for parents e.g.) Anyway, plan B (or C) is to write the data to an SD card onboard the Ethernet shield. But an online data table is far better to work with i.m.o. My students might even consult it from home then, and draw their conclusions.

Nick_Pyner:
I say "very likely" only in terms of comparison with a Uno, because you have brought WiFi in to the game. So note

You may find that a Node-MCU or and ESP32 can do the whole thing - particularly if you cull redundant sensors.
All ESP8266 devices have their own intelligence - and memory. This means they can share the workload in data collection, and I believe that approach probably means a Mega is unnecessary.

ESP8266 and Arduino speak the same language so, while you may find a Node-MCU doing all the real work with Uno just doing the local peripherals, developing on the Uno you already have will not be wasted.

I fear I don't even know what a Nod-MCU or an ESP8266 is or what they do exactly. Do they handle or process data for the ATmega processor? Should I dig deeper into this stuff before I get started? Anyway, I won't use WiFi, it's still a wired connection. The Arduino will be in a server room, connected to a UTP port and connected to the sensors outside (about 8 m further).

wvmarle:
I2C is a bus, meant to have multiple devices connected. Each device indeed should have a unique address on the bus.

On the bus, meaning they have to be adressed specifically in the sketch? Sorry if my questions are dumb :confused:

Are the kids writing the code? Give each group an Uno and one sensor. Teach them a postgraduate-level lesson in software engineering by making all their code work together.

jmuylle:
Should I dig deeper into this stuff before I get started?

You most certainly should.
SQL and stuff is all Chinese to me too, and the same goes for php. I have never understood why anybody would bother with a web page to showcase things when one can send data to an Internet of Things service and show it to the entire world so painlessly. This particularly applies since you have mentioned students accessing it from home.

An ESP8266 can work in conjunction with a Mega and can also replace it, as it has its own intelligence. It is faster and cheaper, and comes with built-in WiFi, hence my comment. It also brings memory to the game and may work in conjunction with Uno, thereby making a Mega unnecessary. It uses the same IDE as Arduino, hence its ease at replacing it. The Node-MCU is an ESP8266 device. Similar is the ESP32 WiFi kit, which I understand is superseding Node-MCU, and has on-board display and bluetooth.

While you have only answered one question, I guess it is yes, or at least eventually, to the others, and a Uno by itself is probably inadequate. One thing about Arduino projects is that they are hard to finish, and you are likely to need more memory for something essential that you didn't think about until next week.

and a swag of Indian students on YouTube

jmuylle:
On the bus, meaning they have to be adressed specifically in the sketch? Sorry if my questions are dumb :confused:

Yes, and that's usually taken care of by the library.

Do read up on I2C. You're going to need a lot more if you want to actually teach it!

Hey all,

I have a first working sketch for my weather station. Not an example of elegant programming (I'm a science teacher, not a programmer), but all sensors seem to work together (esp. the BMP280 and TSL2561 sensors) and I have no power or memory issues. I use both a stabilised 5V (on the board) and 9V (on the Arduino) power source. I have three temperature readings which is of course redundant, but like I've told you that is because of the different student groups, and this way the 'temperature group' can compare measurements, also with a standard thermometer. The 'rain' sensor is a bit of a mockery since the voltage shifts with the resistance of other sensors, but I'll think on that one some more. Velleman has a comparator for those sensors which could make a difference. Anyway it should only tell whether it's dry, drizzling or pouring rain. This version has webserver functionality: it prints all values to a html page on a fixed IP address. A later version should log the readings in a php file, with a little help from my friend the IT manager :slight_smile: . Students will only have to get their own sensor to work with what they find on the internet. That will be hard enough as it is since their programming skills now are practically nihil.

The names of the values and some comments in the sketch are in Dutch, but you'll get the meaning.

Thanks for your support so far :slight_smile:

Jan

allesensoren_webserver.ino (9.19 KB)

Do you have a question?

...R

PS. Please display your image(s) in your post so we can see it(them) without downloading it(them). See this Simple Image Guide

Yes, please post sketches according to the forum guide also.

The Arduino will be in a server room, connected to a UTP port and connected to the sensors outside (about 8 m further).

I2C will probably not work over 8m wires.