Dear all,
I have been perusing the forum over many months, trying to use others' examples to help me understand more about programming the Arduino. Unfortunately the examples I read seem to go too deep before I grasp the main core.
For example: I wish to read several temperatures, and act upon them. Initially I used an 8 channel multiplexer with thermistor inputs to a single analogue input on a Nano. It worked OK, and I could follow the sample code well enough to modify it for my specific project.
Then I was introduced to the Dallas DS18B20, and was instantly converted by virtue of its superior accuracy and the OneWire bus system which both eliminated the limitations and resolution of the analogue inputs, and enabled multiple devices to be read with just one digital input - FANTASTIC!
My problem is that I cannot seem to follow the sample software, and therefore I cannot confidently modify it for my purposes. For example, I started with the code as below:-
/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
/********************************************************************/
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.println("DONE");
/********************************************************************/
Serial.println("Temperature is: ");
Serial.println(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire
Serial.println(sensors.getTempCByIndex(1));
Serial.println(sensors.getTempCByIndex(2));
Serial.println();
delay(5000);
}
The libraries are declared:
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
I can follow this, but when it comes to
sensors.begin();
followed by
sensors.requestTemperatures(); // Send the command to get temperature readings
I get lost.
The pressing questions are 1. How do I find out which library contains the code from where 'sensors.something' comes? Easy when there are two libraries included, but when there are ten?
2. How do I find out what functions are available from within the library, functions which may not be used within the sample code I am trying to learn from, but useful within my specific sketch?
Previously I have been referred to the [name].h file and [name].cpp files on github (at least that's where my enquiries seem to lead), but I have quickly been overwhelmed by the 'stuff', sometimes forgetting why and how I got there in the first place!!!
So I suppose that what I am asking is 'Please will someone point me in the right direction to allow a structured approach to learning how to make the Arduino do what I want'; when I say that, it's not that I don't understand blink, or delay(), or pin assignment, more that I have hit the wall when it comes to understanding libraries, their use, and what they can do for my project(s).
Regards, GM
PS, I have just spent a couple of wasted hours trying to get Fritzing to sketch my project in an attempt to illustrate my latest project - without success (no luck finding a CT symbol on there!), so here is, for those who are interested, a brief outline of the project:
- Measure ac current up to 50A. (Done that)
- Measure several temperatures around an electric central heating system (9kW electric boiler to radiators). This will be where the DS18B20 sensors come in. Hardware safety devices, such as overheat cut-out, have been incorporated, but excluded from this enquiry for simplicity.
- Control the power to the boiler (which has 3 off 3kW elements) via two relays and one solid state relay, to give fully modulated contol between 0 and 9kW. I have the control strategy done, proportional control only will suffice, it just needs coding up.
- Limit the power to the boiler elements so that the total power consumption never exceeds 10kW. Clamp the control output?
- Display relevant data on a 20 x 4 LCD display. (I2C to be learned)
Now I know how to do many of the elements, though maybe without the elegance others' may incorporate, but that will come with time and with knowledge....just clearing some of the fog around libraries will do for now!
For some this may appear to be a rant, and a long one at that; I assure you it's not, but there is an element of frustration. If I can just, with your help and guidance, get past that....GM