B4R Question Arduino newb...

Kevin

Well-Known Member
Licensed User
Longtime User
I have been wanting to create something with one of these things but I'm not really sure where to start. From what I can tell, some of the boards have built-in WiFi, or others you can add an expansion card to give it that functionality.

To give some ideas on what I would like to accomplish:

Device that downloads local weather forecast every morning and if it is calling for cool or rainy weather, disable my pool heater since we would not be using the pool that day anyway. The heater has inputs for remote control like this (similar to how a home thermostat would work to control a furnace or A/C).

Device that monitors pool water level and sends an email, text, etc to alert me to a potential leak.

I have a couple other ideas but I think one of these would be my first project. From what I can tell, you can connect just about anything to these boards. Some have built-in relays or otherwise you could connect external relays.

I'd most likely run these off of A/C with a 5v(?) DC adapter.
 

Kevin

Well-Known Member
Licensed User
Longtime User
Thanks, Erel. So it would appear that ESP8266 would be the chipset to look for. I say this because from a quick search, there seem to be lots of boards based on ESP8266 but with varying numbers of inputs and outputs.

I am extremely green on this stuff. I have a basic understanding of the practically unlimited uses of these devices but I really have no idea how to actually go about connecting various sensors or what the various connections are used for.

I'm definitely open to suggestions in this area, but as this is likely outside the scope of using B4R to program them, I will get myself to Googling. :D
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
This is an exciting world. You'll enjoy it.

Possibly you should begin here: https://www.arduino.cc/ - walk around there a bit and see the tutorials etc on the boards and if you really want to get into it boots and all then look at one of the kits from here or locally for you from here and Remember - You can't beat B4R as your IDE !!

Something to look out for:
1. Most Arduino board will accept between 5 and 12v - BUT
2. The boards put out either a 5v logic or a 3.3 volt logic - make sure they are matched
3. Serial on the boards and serial (RS232 as often referred to) are not the same thing - One runs on 5v and the other on (upto) 23v and this could have dire consequences if you connect them up directly.

Another resource for schematics, virtual breadboards (and even making PCB's afterwards) is Fritzing here

So let's look at your project:

Firstly, you want to get a weather report and use that information to control your pool. Great idea. You could rely on an internet source or make it really interesting by getting a weather station like this one - There are sensors included here that can check water level for you also (but now what do you when people are swimming - erratic readings - I'll leave you to figure that one out - maybe rather an ultrasonic sensor !!)

Once you have decided all this you are going to need a messaging protocol that will work faultlessly, but also let you know what is happening when you are away from home. Try MQTT, something like this or this for Arduino and if you want to write/keep data on the whole affair - try this

Now you are really cooking on gas and decide you want to control your pool pump and pool lights - possibly this could be the answer or this (if you become lazy)

And finally, use an old tablet that is lying around as your control centre - repurpose !!

I trust that I have not confused you too much - but enjoy - this is exciting stuff !!

PS - and we have not even touched on the pH probes, turbidity sensors and automatic pool valves

Enjoy !!
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
There are sensors included here that can check water level for you also (but now what do you when people are swimming - erratic readings - I'll leave you to figure that one out - maybe rather an ultrasonic sensor !!)
For water level I'll take many measures, accumulate in an array and calculate average value. The array should work as a stack, pushing in last value and popping out older.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Thanks for all of the replies!

I definitely have lots to consider. Regarding water loss detection, I am thinking of drilling a hole into the plumbing beneath the skimmer and placing a water sensor there (leakproof, of course, and assuming such a water detecting probe exists). Unless the water level drops below the skimmer, I can't conceive of too many situations where there should be no water there, and if the water level drops below the skimmer then I want to know about that.

When I first heard about these things several years ago I was pretty excited at the possibilities.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Well, I ordered myself a "starter kit" based on some articles I found on the web - ESP8266 boards, power supplies and USB/serial adapters, prototype breadboards & jumpers, relay boards, etc. I didn't find a water sensor that I was happy with but I'll keep looking. Controlling my pool heater based on weather forecast is my biggest priority anyway as it will save me some money.

Would one of these ESP8266 boards still suit my needs if I wanted to add extra functionality such as a web GUI to set options like configuring WiFi settings, static IP address, showing what the device has determined to do (based on weather forecast) for the next 7 days, as well as an option for setting a manual override (to off or on) for each day? Failing that, I would also just make an Android or Java app that retrieves and sets options, leaving the device to just maintain those options.

The boards I purchased have 1 MB of memory but I really don't know what all can be accomplished with that. They will definitely get me started and I can always get something with a bit more processing power and memory if necessary. For example, could these little 8266 microprocessors handle MQTT?
 
Last edited:
Upvote 0

AHilton

Active Member
Licensed User
Longtime User
Sounds like you have a lot of things in mind for your new project. Just start slowly, adding one sensor or feature at a time and don't try cramming everything under the sun in there to start. You'll only be frustrated if you do. The ESP board will do what you mentioned to varying degrees. It's not a full-fledged PC but it does a lot and is a great, versatile item, while capable and cheap, does somethings really well and others should really be done somewhere else.

As far as your water sensor, what you describe needing is exactly that .. a water sensor (as in binary = There IS water where this sensor is located -vs- There ISN'T water) and not a water *level* sensor. I call it a flood or water presence sensor. Those are very simple! Depending on how complicated you really want to make it, of course.

The basics are: just take 2 bare wires (at the ends) and put those ends at the position that you want to know where there is/isn't water in your pool a set distance apart. The other ends .. connect one of them to ground on your ESP and the other end to either the (single) analog or one of the digital pins. Measure the voltage on a input pin on the ESP. If there's no water touching both bare ends, then there's no current passing between them and vise-versa. That's an over-simplification depending on how you want to set it up but that's, essentially, what you're doing. You might need to add a capacitor or pull-up resistor in there and will probably want to clean up the bare-ends with some sort of small encasement to make it look better and last longer. But, that's minor stuff. A flood sensor is about as easy and cheap as it's going to come in sensor-land. Take a look at https://www.b4x.com/android/forum/t...vironment-solution-using-wemos-esp8266.92223/ . There's a raw flood sensor shown there.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Neat stuff! I figured that a water sensor is basically measuring any current between two wires, but I'd have to do some research on how to work in a capacitor or resistor as I don't know much about that sort of thing yet.
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
@Kevin

Take a look at this sensor and at just over $5 - I think it is a bargain. While you are there - take a look at their other stuff as well - Big Boys Playground !!

Enjoy !!
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
@Kevin

Take a look at this sensor and at just over $5 - I think it is a bargain. While you are there - take a look at their other stuff as well - Big Boys Playground !!

Enjoy !!

I just ordered two of them. Thanks for the link! I know these boards and accessories are relatively cheap, but I see this becoming an expensive hobby for me. :D

I used to take electronic things apart as a child (I'm 45 now) and make other things with it. I'm really geeking out now just thinking about all of the possibilities with these devices.

Most of the parts I ordered from Amazon should be here tomorrow. Right now I'm getting everything else set up and looking at sample code to get me started.

I'll Google this anyway, but is there some type of emulator available where we can test things virtually? Even just something that shows the status of various I/O pins as virtual switches and LEDs or something would be handy for writing and testing the code.
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
@Kevin

Some play golf, some drink whisky - we play with Arduino !! - Expense is relative !!

Check this link for a list of Simulators (then you would need to move away from B4R unfortunately) and when you have looked at all that then you download this one

My advice at this stage is to look at all those things but stick with the B4X Suite of software. It makes integration from Desktop, to Android/iOS to sensors much easier.

Take for example, if you need to write data to a MySQL database - will be a nightmare in Arduino Standard (my opinion) but much easier if you use MQTT and jRDC2 and both are accessible from devices, desktop and sensor units.

But - Enjoy and have Fun - that's the most important.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
@BillMeyer

Thanks for the links! Do these emulators emulate non-Arduino boards? One thing I'm a bit unclear on is proper terminology. For example, the microprocessors I ordered are Makerfocus ESP8266 ESP-01S. Are these still considered to be "Arduino" boards? I am assuming so, or at least a clone, but when discussing this or my project with others, I don't know if referring to it as an "Arduino project" would be correct.

I wonder if B4R will ever work with emulators. Not a big deal if it is impossible for technical reasons.

I totally agree on sticking with B4R regarding code development. The B4X IDEs are truly the easiest way to go for RAD on any of their supported platforms. I've been away from programming for a couple years and I am constantly in awe everytime I read something here on a feature or enhancement that I didn't know about (primarily B4A). Erel and the others involved with the development of these apps are awesome.
 
Upvote 0
Top