Recent Posts

Pages: [1] 2 3 ... 10
Exhibition / Gallery / Re: State machine for Arduino ...
Last post by 6v6gt - Today at 09:27 am
I looked quickly through and it appears very nicely put together.

I guess the main issue for a beginner is (a) recognising whether a specific real world problem is a candidate for the state machine approach and then (b) modelling that problem as a state machine in a systematic way.
Once that level has been achieved, the translation of the state machine model into code should be a relatively straight forward exercise.

I did a simple example for someone here and it was basic enough to describe in an excel table and I left the code more or less 1:1 with the table (although it could be optimised).
Generale / Re: standalone 328
Last post by Etemenanki - Today at 09:27 am
Quello schema a livello di principio e' sbagliato ... fa passare il GND all'interno dell'integrato, cosa da non fare mai ... in piu, non cita appunto i condensatori di filtro, che sarebbero sempre da mettere (al limite anche uno solo, dato che i pin sono vicini e se si usa un doppiafaccia si possono ponticellare entrambi sotto l'integrato, ma ALMENO uno serve metterlo)
Project Guidance / Messaging protocol guidance
Last post by netamity - Today at 09:27 am
I'm hoping you can provide some initial guidance to me as a newbie to help me find the right approach for what I want to do.

I am a web developer who'd like to make IoT devices that server as 'assistants' or 'cryers' or 'personas' for websites.

An example might be if I had an online shop. I would install a plugin into the shop that triggered an event when someone made a purchase and sent a message to an IoT device which would light up / vibrate, etc. This would allow owners of websites to be alerted to events on their website without needing to be logged in, and hopefully in a fun way.

Particulars of what I need:
- One to one messaging (at least at the start, no need for broadcast / one to many / many to many)
- Over different networks. The website would live on a web server somewhere, and the device would be on a home or business wifi connection, so this must be an internet connection, not a local one.
-Use widely accepted ports / protocols - as I'd like to send these out to other people, I don't want them having to configure routers and firewalls to accept connections. This applies to people's web server environment where their site is hosted, and also their home/office network where the device is connected
-Encryption. It's important that usernames and passwords sent out by the device in order to subscribe/receive are not sent unencrypted.
-Energy-efficient. As much as practical, I'd like to reduce the energy load for the process. The devices will be on mains, so it's not crucial, and given my requirement for encryption, I know this will take a hit.

I have looked at MQTT, set up a broker, but I cannot get my web app to publish, let alone the device to subscribe. I don't know why it's not working, the error message doesn't provide enough to go by. I've left a forum message here: , but didn't get any response.

I'm a web developer, so I'd really prefer to use http as the system. It's a protocol I understand and its widely accepted, and I can secure things. The advantage of this is that the device can poll the web plugin I create directly rather than needing a broker. The idea is that I'd send these out to business partners who can easily install the plugin on their website and connect the device on their home network and it just works, no needing their own broker server or configuring firewalls, etc. Given the business-sensitive nature of the data being sent, I'd rather it wasn't on a 3rd party server I provide, but go directly between the user's site and their device.

I'm just wondering if the energy consumption of the device pinging a server every couple of seconds over https would be extremely wasteful.

I'm going to build out an http proof of concept over the next week. I know how to do the web application side of things, and I'm hoping there's good docs on the device side of things which I know less about (but thinking http is ubiquitous, so there must be good info out there), but if people have comments, pointers, red flags, existing examples, etc, I'd really love to hear from you
I got it working now, changed some things here and there (in the sketch and the code in the SD file). The below code is the working one, I'll also include the SD sketch so other people can take this code and have a working webserver which monitor IRT three analog values.

Everyone thx for the help appreciate it thanks alot.

Hope other people see this post and try it and learn from the mistakes i made.

Code: [Select]
#include <SPI.h>
#include <Ethernet2.h>
#include <SD.h>

// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   50

// MAC address from Ethernet shield sticker under board
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 10, 2, 143); // IP address, may need to change depending on network
EthernetServer server(80);  // create a server at port 80
File webFile;               // the web page file on the SD card
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer
//const int ss = 53;

void setup()
  //pinMode(53, OUTPUT);
  /* disable Ethernet chip
    pinMode(10, OUTPUT);
    digitalWrite(10, HIGH);*/

  Serial.begin(9600);       // for debugging

  // initialize SD card
  Serial.println("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("ERROR - SD card initialization failed!");
    return;    // init failed
  Serial.println("SUCCESS - SD card initialized.");
  // check for index.htm file
  if (!SD.exists("index.htm")) {
    Serial.println("ERROR - Can't find the index.htm file!");
    return;  // can't find index file
  Serial.println("SUCCESS - Found index.htm file.");

  Ethernet.begin(mac, ip);  // initialize Ethernet device
  server.begin();           // start to listen for clients

void loop()
  EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {   // client data available to read
        char c =; // read 1 byte (character) from client
        // buffer first part of HTTP request in HTTP_req array (string)
        // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
        if (req_index < (REQ_BUF_SZ - 1)) {
          HTTP_req[req_index] = c;          // save HTTP request character
        // last line of client request is blank and ends with \n
        // respond to client only after last line received
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          // remainder of header follows below, depending on if
          // web page or XML page is requested
          // Ajax request - send XML file
          if (StrContains(HTTP_req, "ajax_inputs")) {
            // send rest of HTTP header
            client.println("Content-Type: text/xml");
            client.println("Connection: keep-alive");
            // send XML file containing input states
          else {  // web page request
            // send rest of HTTP header
            client.println("Content-Type: text/html");
            client.println("Connection: keep-alive");
            // send web page
            webFile ="index.htm");        // open web page file
            if (webFile) {
              while (webFile.available()) {
                client.write(; // send web page to client
          // display received HTTP request on serial port
          // reset buffer index and all buffer elements to 0
          req_index = 0;
          StrClear(HTTP_req, REQ_BUF_SZ);
        // every line of text received from the client ends with \r\n
        if (c == '\n') {
          // last character on line of received text
          // starting new line with next character read
          currentLineIsBlank = true;
        else if (c != '\r') {
          // a text character was received from client
          currentLineIsBlank = false;
      } // end if (client.available())
    } // end while (client.connected())
    delay(1);      // give the web browser time to receive the data
    client.stop(); // close the connection
  } // end if (client)

// send the XML file with switch statuses and analog value
void XML_response(EthernetClient cl)
  int analog_val1;
  int analog_val2;
  int analog_val3;

  cl.print("<?xml version = \"1.0\" ?>");
  analog_val1 = analogRead(1);

  analog_val2 = analogRead(2);

  analog_val3 = analogRead(3);

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
  for (int i = 0; i < length; i++) {
    str[i] = 0;

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
  char found = 0;
  char index = 0;
  char len;

  len = strlen(str);

  if (strlen(sfind) > len) {
    return 0;
  while (index < len) {
    if (str[index] == sfind[found]) {
      if (strlen(sfind) == found) {
        return 1;
    else {
      found = 0;

  return 0;

Code: [Select]
#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only

  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");

  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile ="index.htm", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening index.htm");

  // re-open the file for reading:
  myFile ="index.htm");
  if (myFile) {

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening index.htm");

void loop() {
  // nothing happens after setup
Project Guidance / Re: Getting a Weather Balloon ...
Last post by srnet - Today at 09:26 am
I have read about, but have no feel for LoRa, but it seems to be able to work for kliometers.

anyone know if it can be triangulated ?  seems a LoRa sender could be used to pulse out a signal every so often and then allow you to triangulate it's postion ?

Triangulation by signal strength comes up in here often, from ground to high altitude balloon is one situation where it might work since there is usually very good line of sight between ground the the transmitter.

However there is no real need to use traingulation at all, just put a GPS on the tracker and get the accurate location back in anycase.

LoRa balloon tracker can be very simple, see below. The full distance capability of LoRa trackers is yet to be discovered, the current recors stands at 702km from a balloon to a TTN\LoRaWAN node , 868Mhz, 25mW.

You can use the same board as the receiver to.
Generale / Re: ordinare PCB
Last post by Etemenanki - Today at 09:23 am
Visti "al volo" per ora ... ma gia cosi ... qualche imperfezione, alcune piste che possono passare in modo migliore, un sacco di angoli retti da eliminare (bisognerebbe sempre evitarli), piste che fanno giri strani (dato che fai comunque dei doppiafaccia, abituati ad usare anche il lato superiore, e vedrai che in molti casi ti semplifica la vita di parecchio) ...

Oggi semmai gli do un'occhiata piu approfondita e ti faccio sapere piu in dettaglio ...
this program designed for building arduino library fast and easy
Can you explain more clearly what it is that your program actually DOES?   I don't group "build library" and "beginner" together!
Generale / Re: ordinare PCB
Last post by gpb01 - Today at 09:22 am
Guglielmo non capisco come si usano i file che hai postato
mi spiegheresti in dettaglio?
Prendi i due files, il .dru lo metti nella cartella di Eagle "dru", il .cam in quella chiamata "cam" ... e fino qui mi sembrava ovvio ...

Ti metti sulla board :

Il dru ti serve per controllare se rispetti le specifiche di disegno (larghezza minima delle piste, distanza tra di loro delle piste, dei pad, diametro dei fori, ecc) e lo lanci dal menu di Eagle "Tools -> DRC", con il bottone <Load> lo carichi, e poi con il bottone <Check> esegui il controllo.

Il cam ti serve per generare i corretti files gerber (e non quella marea di files che hai generato tu) ...
... avvi il "CAM processor" (l'iconcina con quelle che sembrano due pezzi di negativo fotografico), dal menu in alto, "File -> Open -> Job" selezioni il .cam e poi usi il bottone <Process Job> per generare automaticamente i files necessari con il corretto nome ed estensione.

Project Guidance / Re: A ball that lights up when...
Last post by gdsports - Today at 09:20 am
If you are looking to program in Python, take a look at the Adafruit CircuitPython boards such as the following. You get a lot of hardware (SAMD, RGB LEDs, accel, DAC+speaker, etc.) on one board. And it can be programmed using Arduino as well. It is designed for anyone new to electronics and embedded software.
Generale / Re: ordinare PCB
Last post by giondalar77 - Today at 09:18 am
Grazie mille anchio so o arrivato a fare una cosa simile ma con un file diverso...

Posso sapere dove acquisti? I costi sono contenuti?

Pages: [1] 2 3 ... 10