Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hardware Prototyping with Arduino

Taylan Pince
November 28, 2014

Hardware Prototyping with Arduino

These are the slides from my talk at Full Stack Toronto conference on November 23, 2014 in Toronto. I also blogged about the subject here: http://hipolabs.com/en/blog/hardware-prototyping-arduino/

Taylan Pince

November 28, 2014
Tweet

More Decks by Taylan Pince

Other Decks in Technology

Transcript

  1. HOME MONITOR ▸ Temperature ▸ Humidity ▸ UV Levels ▸

    Noise Levels ▸ Luminance Delivered over WiFi to central database
  2. app = Flask(__name__) app.db = dynamodb2.connect_to_region(AWS_REGION) @app.route("/entries", methods=["POST"]) def create_entry():

    with app.db.table.batch_write() as batch: for entry_type in dict(ENTRY_TYPES).keys(): batch.put_item(data={ "entry_type": entry_type, "date_created": int(time()), "reading": request.json.get(entry_type) }) return Response(status=200)
  3. /* Temperature & Humidity */ float temperature = TH02.ReadTemperature(); float

    humidity = TH02.ReadHumidity(); /* UV */ long uv_exposure = analogRead(A2); /* Luminance & Noise */ int luminance = analogRead(A3); int noise = analogRead(A1);
  4. client.fastrprint(F("POST ")); client.fastrprint(endpoint); client.fastrprintln(F(" HTTP/1.1")); client.fastrprintln(F("Content-Type:")); client.fastrprintln(F("application/json")); client.fastrprint(F("Host: ")); client.fastrprintln(server_host);

    client.fastrprint(F("User-Agent: ")); client.fastrprintln(user_agent); client.fastrprint(F("Content-Length: ")); client.println(length); client.fastrprint(F("Connection: close")); sendData(client, payload, buffer_size);
  5. // Enable watchdog wdt_enable(WDTO_8S); for (int i = 0; i

    < total_packets; i++) { client.print( payload.substring(i * buffer_size, (i + 1) * buffer_size)); // Reset watchdog wdt_reset(); } // Disable watchdog wdt_disable();
  6. uint32_t temperature = myBarometer.bmp085GetTemperature( myBarometer.bmp085ReadUT() ); BLEMini_write(0x0A); BLEMini_write(temperature >> 24);

    BLEMini_write(temperature >> 16); BLEMini_write(temperature >> 8); BLEMini_write(temperature);
  7. - (void)bleDidReceiveData:(unsigned char *)data length:(int)length { for (int i =

    0; i < length; i += 5) { Float32 readingValue = data[i + 1] << 24 | data[i + 2] << 16 | data[i + 3] << 8 | data[i + 4]; if (data[i] == 0x0A) { NSLog(@"TEMPERATURE: %1.2f Celcius", readingValue); } else if (data[i] == 0x0B) { NSLog(@"PRESSURE: %1.2f Pa", readingValue); } else if (data[i] == 0x0C) { NSLog(@"ALTITUDE: %1.2fm", readingValue); } } }