Arduino GPS Code for GPS/GPRS/GSM Module V3.0 (SKU:TEL0051) loaded

Arduino GPS Code for GPS/GPRS/GSM Module V3.0 (SKU:TEL0051) loaded.

20140727-031035-11435603.jpg

http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_%28SKU:TEL0051%29#How_to_drive_the_GPS_Mode_via_USB_port

Quite a bit of research to get the boards code, configure the arduino IDE and latest GitHub code.

Now I have to go outside to get a GPS signal.

20140727-031152-11512745.jpg

Update: Was able to send a text message from the Arduino/gsm module Telstra pre paid sim via power pack alone. It turns out we need to redirect pins 3/4/5 to 11/12/13 :)

20140727-162112-58872675.jpg

20140727-162734-59254900.jpg

My first standalone ATmega328P/arduino breadboard

Having played with a Freetronics TwentyTen for a while I now want to build my own ATmega328P MCU powered devices running from batteries as cost affective as possible.

I followed this guide and ordered the parts for 2x solo units. I ordered the ATmega328P MCU etc from http://www.wiltronics.com.au.

willatmega328p

Maybe I should have ordered this one from freetronics. The label on the freetronics chip would be handy.

Freetronics_ATmega328P_with_bootloader_and_label_002_medium

This was the result of replicating the standalone arduino system on a breadboard.

The breadboard wire kit did not have a lot of red and black wires so please forgive the crazy colours. I did not have a momentary switch so I got creative with two vertical wires.

standalone_arduino_01a

One stumbling block was how do I program my arduino (as I did not have a stand alone programmer). I tried removing the existing chip from the Freetronics TwentyTen but it would not budge. I tried with more force but the chip would not budge. On closer inspection I could not see if the chip was soldered into the DIP socket (Googling did not say if it was or not). I considered de soldering the square style dip socket and replace it with a round style dip socket that uses less force. But luckily I decided to gently lever up the chip on both sides with a flat screwdriver and bingo, the chip popped out.

standalone_arduino_01b

Programming Considerations.

The chip that came in the Freetronics TwentyTen needs to be programmed as:

      • Board: Arduino Nano w/ATmega328
      • Programmer: AVR ISP

 

The ATmega328P MCU chip that came from Willtronics needs to be programmed as:

    • Board: Arduino Uno
    • Programmer: AVR ISP

 

The Result

standalone_arduino_01d

Where to Next

Moving from a large breadboard down to a permanent circuit soldered to a board and actually driving sensors etc.

standalone_arduino_01e

Virtual COM Port (drivers) not installing via Arduino.cc IDE on Windows 8.1

I recently performed a clean install to Windows 8.1 and found that there was no COM port driver loaded for my ATmega328P Microcontroller (TwentyTen Arduino compatible) from Freetronics when installing the Ardrino.cc 1.0.5 IDE.

    tt_top_01_480w_large

I read the getting started guide.pdf at freetronics with no luck. Opening the device manager and automatically searching for driver does not work on Windows 8.1.

A quick google revealed this virtual com port driver that is WHQL certified for Windows 8.1

Win81COMDriver

Soil Hygrometer Moisture Water Sensor for Arduino

The Hardware

Purchase for less than $2 from eBay.

MoistureProbe

The Wiring

  • VCC = 5V
  • GND = GND
  • DO = Digital 2
  • AO Analog 1
  • MoistureProbe2

The Code

    const int VAL_PROBE = 1; // Analog pin 0
    void setup() {
    Serial.begin(9600);
    }
    void loop() {
    int moisture = analogRead(VAL_PROBE);
    Serial.println(moisture);
    delay(100);
    }

The Output

  • Mid Air = 667
  • Soil (in a cup after 3mm Rain) = 539
  • Tongue = 319
  • Soil (in a cup with a few teaspoons of water added (tap water)) = 284
  • Soil (in a cup with a maximum saturation (tap water)) = 162
  • Soil (in a cup with a maximum saturation (tap water with salt added)) = 59

Working J204A 4×16 LCD from Arduino w/LiquidCrystal.h

Connected a 4 Row LCD to an Arduino.

Wiring

    LCD Pin Connect to
    1 (VSS) GND Arduino pin*
    2 (VDD) + 5v Arduino pin
    3 (contrast) Resistor or potentiometer to GND Arduino pin*
    4 RS Arduino pin 12
    5 R/W Arduino pin 11

    6 Enable Arduino pin 10
    7 No connection
    8 No connection
    9 No connection
    10 No connection
    11 (Data 4) Arduino pin 5
    12 (Data 5) Arduino pin 4
    13 (Data 6) Arduino pin 3
    14 (Data 7) Arduino pin 2
    15 Backlight + Resistor to Arduino pin 13**
    16 Backlight GND GND Arduino pin*

Code

    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
    int backLight = 13;
    void setup()
    {
    pinMode(backLight, OUTPUT);
    digitalWrite(backLight, HIGH);
    lcd.begin(16,4);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Hello, World");
    lcd.setCursor(0,1);
    lcd.print("LCD Working");
    lcd.setCursor(0,2);
    lcd.print("On Arduino");
    lcd.setCursor(0,3);
    lcd.print("Simon Fearby");
    }
    void loop()
    {
    }

Pictures

20131201-032357.jpg

20131201-032417.jpg

Now I can integrate a LCD’s into Arduino projects (reporting sensors, activity, logs, history etc).

Thanks to this guide and to Gams for the hardware.

Connecting a Freetronics Twenty Ten to a HanRun Ethernet Adapter

Connecting a Freetronics Twenty Ten to a HanRun Ethernet Adapter (ENC28J60 Ethernet LAN+Network Module)

hanrun2

hanrun1

What hardware you will need

  • 1x Freetronics TwentyTen
  • 1x HanRun HR911105A 12/18 Ethernet Board (eBay)
  • Misc Solder-less breadboard cables (Male/Female)

Router Configuration

I prefer to assign static IP’s to any of my test devices (Arduino or Raspberry Pi). This way I know what the IP is in case I need to connect to it. If you want to use your arduino in a Dynamic IP network then you may not have much luck with this guide as I am configuring the arduino to use an static ip that I have reserved in my router.

    Arduino Static

The HanRun Ethernet adapter does not have a mac address built in so I made one up ( 00:12:34:43:21:00 ), you can generate mac addresses here http://www.miniwebtool.com/mac-address-generator/.

Software Configuration

  • Arduino.cc IDE (Set the ‘Board’ to ‘Arduino Nano w/ ATMmegda 328’ and the virtual serial port for your USB cable)
  • Download ‘Ethercard’ from https://github.com/jcw/ethercard (add it as a library into arduino.cc IDE)

The Wiring

HanRun Side | Arduino Side

    GND = Power Ground
    SCK = Pin 13
    SO = Pin 12
    VCC = Power 3V3
    CS = Pin 8
    SI = Pin 11

photo 2

    The Code
    Now this is my code solution for returning a date from a website (php script). Yu can change the IP, Gateway, Server Name, IP and Path to your server if need be.

    // This demo does web requests to a fixed IP address, using a fixed gateway.
    // 2010-11-27 http://opensource.org/licenses/mit-license.php
    // 2013-11-23 Modified by Simon Fearby

    #include
    #include

    #define SLEEP_TIME_AFTER_SETUP 10000 // How often do we poll the server

    //static long timersetup; // Used to remember the last millisecond for the last call (during setup)
    static long timerloop; // Used to remember the last millisecond for the last call (after setup)

    static byte mymac[] = { 0x00, 0x12, 0x34, 0x43, 0x21, 0x00 }; // ethernet interface mac address
    static byte myip[] = { 192,168,1,201 }; // ethernet interface ip address
    static byte gwip[] = { 192,168,1,1 }; // gateway ip address
    static byte hisip[] = { 175,107,162,121 }; // remote website ip address and port

    char website[] PROGMEM = "fearby.com"; // remote website name

    byte Ethernet::buffer[1000]; // a very small tcp/ip buffer is enough here

    void setup () {
    Serial.begin(57600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
    }
    Serial.println("Ready");
    if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
    Serial.println( "Error Failed to access Ethernet controller");

    ether.staticSetup(myip, gwip); // Our router has a Static IP already setup for us so dont ask for a IP via DHCP
    ether.copyIp(ether.hisip, hisip); // Is it the IP we expect?

    ether.printIp("My Gateway: ", ether.myip); // Output the routers IP (Gateway)
    ether.printIp("My IP: ", ether.gwip); // Output the Arduino's IP)
    ether.printIp("Remote Server: ", ether.hisip); // Output the IP of the remote server.

    while (ether.clientWaitingGw()) // Check to see if the gateway is up before moving on.
    ether.packetLoop(ether.packetReceive());

    Serial.println("Gateway found"); // Congrats, Move on

    Serial.println("Waiting 10 seconds before polling data."); // Congrats, Move on

    }

    static void my_result_cb (byte status, word off, word len) { // called when the client request is complete
    Serial.print("<<< reply "); // We got a reply from the web server Serial.print(millis() - timerloop); // Time Stuff Serial.println(" ms"); // Print the time diff between the call and data received Serial.println((const char*) Ethernet::buffer + off); // Ok print the contents of the webpage } void loop () { ether.packetLoop(ether.packetReceive()); // Process Incoming Packets if (millis() > timerloop + SLEEP_TIME_AFTER_SETUP) { // Do we need to sleep? We dont want to load a website 10,000 a second.
    timerloop = millis(); // Remember the last time we loaded the webpage
    Serial.println("\n>>> Webpage Request Sent.."); // Lets get a Webpage
    ether.browseUrl(PSTR("/temp/printdate.php"), "?", website, my_result_cb); // Query Google
    }
    }

    Result from the Arduino

    hanrun3

    Where to now

    Remember that this code running on a small circuit board that runs < 20Mhz 8bit processor that can be powered by AA batteries.

    You can point to your own scripts and save/read database values or trigger other Arduinos or external processes.

    The next step is to have this device read from any external sensors or control the physical world around us with expansion cards.

Quest to learn to build and program electronics

I have decided to create another blog category on my personal blog to throw information and progress while expanding one of my earliest childhood interests “electronics”. Like many other kids I looked at electronic XMAS toys and wondered how they really worked inside. This resulted in me grabbing the nearest screwdriver (pointy knife) and opening the toy with much vigour and excitement. Often I would break something and I would forgot what order to reassemble it in and the toys would never be the same again (remote control semitrailer and electronic battle ship game comes to mind, sorry mum). But one the toys was opened my mind went nuts, I could see batteries, motors, lights, fans, wires and funny coloured bits (resistors and capacitors) power thingies etc.

When I was a child I remember my grandads sheds (he had a few as he moved house every 6 years or so), sometimes my granddad was in his shed fixing something (mower blades or tools). He always had neatly arranged tools and boxes of stuff and jars with nuts and bolts. I had a great time playing in his sheds and searching for things to do and play with. I want to pass on my fascination of electronics and programming to my kids in a similar environment to my grandads shed and also automate my home and make some cool gadgets along the way.

Part of my quest to learn electronics (for real) was triggered by my desire to fill my 3yo son’s (and soon to be 2nd child) minds with knowledge, wonder and a more than basic knowledge in STEM (Science, Technology, Engineering and Maths), electronics can help teach a fair bit of this as well and hands on experience. Also learning electronics is a kind of stress reducer, work/home demands are always changing but electrical knowledge all but stays constant (apart from miniaturization of components).

I find it quicker to do date calculations in code in excel so I am sure I will be able to program the electronics with ease but I have no doubt it will be an uphill battle teaching this old dog all the ins and outs of electronics (the right way). I will be hitting google a fair bit when it comes to searching for information and schematics and I would lie to share that with kids and older tinkerers.

Post01a

With a second child on the way I need a non-time consuming hobby to use to distract my 3yo when bubby 2 and mummy need a rest and to read up on in the small hours when I am putting baby to sleep.

Learning Goals:

  • Learn basic Electronics (components and theory).
  • Learn to program a Raspberry Pi
  • Create and control basic electronic circuits, read sensors, move mechanical objects and talk to the internet.
  • Learn to scale down code and hardware to the Arduino‎ platform.
  • Fix household items.

Physical Goals:

  • Create a battery powered Arduino circuit to install in the greenhouse to auto mist in hot weather from tank water). Report on temperature, and humidity.
  • Create a 100% automatic weather station that uploads details about temperature, humidity, barometric pressure, wind speed, smoke detectors, wind gusts, dew point, solar exposure, cloud cover, rainfall, soil moisture etc (how: many cheap sensors and custom circuits).
  • Create a battery powered automatically arming home security system with cameras, sensors (pressure, line of sight intrusion detection, magnetic car detection in the driveway, sonic, movement, infrared etc), sms and email alerts with offsite image backup.
  • Home automation (air conditioner on/off, watering system, wild bird seed deployment, rain cover, water tank level reporting, smoke detector (inside and out) remote bushfire protection (recycling roof sprays) etc) (how: many cheap sensors and custom circuits).
  • Remote control grey-water diverted from the shower (how: waterproof remote and 80mm solenoid to divert flow).
  • Auto detect and count bird species at the bird feeder (how: webcam and image processing).

  • Automatic home brew temp system for my dad.
  • Weather cam for my mum.
  • Fun kids projects, remote control robots.

Costs:

Setting up for a Raspberry Pi and or Arduino is about $100 each, much less than gold clubs.
Raspberry Pi Board.

Post01b

Choices of Arduino boards and bits.

Post01c

Sensors are dirt cheap on ebay (about $3 each) and are often compatible with the Raspberry Pi and Arduino boards.

Post01d

I already have a Raspberry pi and Arduino and have started my quest, watch this space.