söndag 10 juli 2016

OS X communicating with an Adafruit Gemma

Background/Problem

I bought an Adafruit Gemma to make a LED enhanced vest for my dog to wear during the dark part of the year up here in northern Europe, but I could not get it to talk to my OS X. When connecting it, the red LED did not blink, but instead gave off a steady red light.

An Adafruit Gemma.


As with my Adafruit Trinket, I tried with multiple cables without success.

Solution

I got a cheap USB 2.0 hub and connected it to my Adafruit Gemma through that one, and immediately the red LED started to blink to indicate that the boot-loader was operational!
A PlexGear USB 2.0 hub.

While it never showed up as a PORT menu option in Arduino IDE, I could load sketches in the same way as I did with my Adafruit Trinket:
  1. Made sure I had the programmer set to USBTinyISP
  2. Loaded up the Blink example sketch
  3. Clicked the Gemma's reset button
  4. Clicked the 'Upload' button from Arduino IDE.
Tada!

OS X communicating with an Adafruit Trinket

Background/Problem

Some time ago I bought an Adafruit Trinket (5V). But try as I might, I never got it to communicate with my OS X.

An Adafruit Trinket 5V

I tried with multiple Mini-USB cables I had lying about.. USB-hubs.. old macs, new macs.. You name it.. I never got to see it show up with a valid port in Arduino IDE.

Solution

I bought yet another USB hub together with a new mini-USB coord, and behold! The red-LED started to flash instead of just shining! Holding my breath I pulled up the PORT menu to check if I could finally see it there, but no, no such luck..
A PlexGear USB 2.0 hub.


Then I remembered that once when I had done some less clever programming that led my Adafruit Feather to refuse to show up when connected, the solution was to double click the reset button (starting the boot-loader) while uploading (less disruptive) code to it, and then the Feather once again showed up under available PORTs.

So this is how I finally got it to work:
  1. Made sure I had the programmer set to USBTinyISP
  2. Loaded up the Blink example sketch
  3. Ensured that my Trinket was connected to the USB 2.0 hub
  4. Clicked the Trinkets reset button
  5. Clicked the 'Upload' button from Arduino IDE.
And while I never got the Trinket to show up under PORTs, the sketch was successfully loaded to my Trinket and it happily blinked at me!




söndag 19 juni 2016

Using HC-06 Bluetooth with Adafruit Feather



Well.. To be honest this was not at all what I was working on right now, but after stumbling about for a bit I feel like I should share some little discoveries I made while poking with my Adafruit Feather M0 Adalogger and a recently bought cheap HC-06 bluetooth card.. So here goes..

The sad background

While working on my 433 enabled door-lock, I got sort of annoyed with that the boards 3.3V was not enough to get any range on my 433 receiver, so I went out and bought a Trinket. After a few hours of trying to get that to work with my mac I gave up... The helpful service at Adafruit told me that the bootloader of the Trinket probably was damaged and gave instructions on how to reset it.. But I did not own the Arduino-board necessary for that trick so I just shoved the Trinket into a dark little drawer where it will have to remain until I've forgiven it.
An Adafruit Feather M0 Adalogger


Next I went and bought a ESP8266-01 WIFI-card and spent around two days with it before shoving it into the dark drawer where it will have to spend some time with the Trinket. I  am not sure if the problem was with using a non-standard board (my Feather) or if that card just sucked, but it was a painful experience.
My worst enemy so far, the troublesome ESP8266-01

Enter Bluetooth

I then decided to try my luck with Bluetooth. I went out and bought yet another cheap little card, the HC-06, and this time it worked out fine!
The HC-06 card in all its glory.

Schematics/Pins

Hooking it up to my feather was pretty easy, the only thing I missed originally was that I should of course switch the RXD/TXD ports so that the TXD port on the HC-06 went to the RX port on my Arduino, and the RXD port on the HC-06 went to the TX port on my Arduino.
Please note that in this diagram I used a Adruino Micro-board as I could not find a Adafruit Feather one. Make sure you use the correct ports on your Feather and do not follow the port layout of the diagram above!

So the ports go:
ArduinoHC-06
3.3VVCC
GNDGND
TXRXD
RXTXD 

This is what my setup looked in real life.

Pairing

Okay, I hooked up the board to my OS X using an USB cable. The red LED on my Feather turned on and the red LED on the HC-06 started to flash madly.

I went into the Bluetooth settings of my OS X and checked for devices. Among the found devices was "HC-06". I selected to pair with it, waited out the inevitable fail :) and then retried now that I got to enter the pairing pin ("1234" without the quotes).

Pairing worked out fine and the red LED on the HC-06 stopped flashing and instead produced a steady light to show it was connected.

After a few seconds the HC-06 disconnected and started to flash wildly again. This did not bother me as I intended to hook it up using the serial monitor of the Arduinio IDE instead.

Coding

So then I fired up my Arduino IDE and configured the Board to be the Adafruit Feather M0 and used the normal port with that.

I then took the echo-script I found on an great Instructable by .
This wont work straight out of the box with the Adafruit Feather though, as the TX and RX pins are referred to as Serial1 and not Serial (which is the one the  USB port is using).
With this little change, the echo sketch now looked like this:

String message;

void setup()
{
  Serial1.begin(9600);
}

void loop()
{
  while(Serial1.available())
  {
    message+=char(Serial1.read());
  }
  if(!Serial1.available())
  {
    if(message!="")
    {
      Serial1.println(message);
      message="";
    }
  }
  delay(5000);
}


 With that little adjustment I verified the code and uploaded it to my board.

Test run

With the USB cable still connected to my OS X (for power), I switched the port to be the Bluetooth one (it contains HC-06 as part of its name), and then fired up the Serial Monitor.
After a few seconds the Serial Monitor popped up, and at the same time the madly blinking LED on the HC-06 was replaced by a steady light signaling that the HC-06 was hooked up.

I then sent a text string to the device, and got it echoed back. Success!

Lessons learned

Not much to say.. Make sure to connect TXD to RX and RXD to TX and also, use Serial1 when trying to use TX/RX as serial ports on the Adafruit Feather M0 Adalogger.
 



lördag 21 maj 2016

Analog reading of the soil moisture sensor






The other day I bought a Soil moisture sensor from a local shop while waiting for the online store to send me the stuff I recently ordered. Buying it from the physical local store was of course nearly ten times as expensive, but it allowed me to get a little one-on-one time with the thing before I get stared for real with the plant-watering project.
As I want to have analog readings from the plant-pots and flowerbeds,  I am going to let my AdaFruit Feather M0 Adalogger be responsible for communicating with the sensors. This little beauty has six analog ports which should hopefully be enough for my needs. If not, I can always add more boards (or shields with analog ports).


Using my breadboard, I simply connected the analog pin of the Soil moisture sensor's analog-pin to analog port A1 (port 15) on the board. I then connected the ground-pin of the Soil moisture sensor to the ground-port on the board and finally connected the VCC-pin of the Soil moisture sensor to the 3.3V-port on the board.

The sensor is supposed to return a value between 0 and 1024, where the higest value is telling us that no power can be transmitted between the

In the Arduino IDE, I added a small sketch to allow me to read the values of the sensors at given intervals and print these to the serial port. (You can grab the sketch from here).

The value read from the sensor is supposed to be an integer between 0 and 1024.

I made a small sketch that just reads the value from the sensor so that I can validate that I receive 1024 when having the sensor in the air, and 0 when dipping it into water.

Running the sketch while having the sensor in the air gives me the following reading:
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Pin 15 = 1018
Please note that "15" is the actual pin number that I reference as "A1" in my Sketch. For more pin information for this board, visit this page.   

So, for my sensor, 1018 is extreme dry.

Submerging the sensor into water gives me the following reading:
Pin 15 = 115
Pin 15 = 115
Pin 15 = 114
Pin 15 = 113
Pin 15 = 114
Pin 15 = 114
Pin 15 = 114
Pin 15 = 114
Which tells me that for my sensor, 113 is extreme wet.

So, I updated my Sketch to take this into account by changing the max value to be 1018-113 and to remove 113 from the sampled value when calculating the percentage.

Okay, so with this hopefully correctly done, it was high time  for a real-world test. So I inserted the sensor into the soil of a newly watered tomato-plant of about 50 cm of height in a 15 liters flowerpot.  It gave me the following reading:

Pin 15 = 93.37 %
Pin 15 = 93.70 %
Pin 15 = 93.81 %
Pin 15 = 93.70 %
Pin 15 = 93.92 %
Pin 15 = 93.25 %
Pin 15 = 93.36 %
  After a while it stabilized and reported a reading like
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
Pin 15 = 95.25 %
So, I think this will be fine for me in my plant-watering project. I was a little annoyed that I could not calibrate the analog reading on the moisture sensors board (it only seem to affect the digital LOW/HIGH setting), but other than that it worked fine. The sensors are a bit on the expensive side, especially as I've read multiple reports warning about that they deteriorate quickly... But building my own sensors seems like such a time sink so I think I will happily pay for them.





onsdag 18 maj 2016

Ardunio 433 Receiver

Yesterday I received my Adafruit Feather M0 logger that I aim to use as sampler of soil moisture in my ongoing plant-watering project.


As I had an extra 433 receiver lying about I decided to try and see if I could read my Nexa doorbell from it.

I quickly put the Arduino board on a breadbox and connected the three jumperwires (ground, 3.3v and data) between the receiver and the board so that data went to the boards port 12.

In order to get the the Ardunio IDE to recognize my Adafruit board I had to follow the steps oulined here, which were quick and easy to go through.

I then uploaded the receiver script written by Peter Mead and Barnaby Gray found on the Arduino playground to my Arduino.

The board happily accepted the program and I fired up the serial monitor of the Arduino IDE to see if I my setup would pickup the signals sent by the doorbell.

With a big smile I saw how the output from the program filled the monitor as I pressed away on the doorbell. The smile fainted however when I moved more than a few centimeters away from the antenna of the receiver and noticed how it stopped picking up signals.

This was however no big surprise as I had the same experience using the Raspberry PI earlier on. In short, the 3.3V that I can use on this board (and earlier on with the Raspberry) was just not enough to get any range with this 433 receiver.

But other than that, my first adventure with an Arduino was a success.

I really enjoyed the simplicity of working with the Arduino and how fast I could go from thought to working prototype without any hassle.

I also enjoyed the slick design of the board I used. I wish there was a 5V version of it so I could go all-in on making a Arduino-based 433-bridge for my otherwise Razberry based home automation system.


I think this board will be perfect for the soil moisture project!

Welcome fellow tinkerer!

Welcome to this litte blog where I will try to keep notes of my tinkering with various gizmos such as Raspberry PI, Arduino and other toys that allows me to participate in the Internet of Things.
Hopefully some of my notes might come in handy for some other lost wanderer in this amazing land of endless possibilities!