WEEK 15

COMMUNICATION AND NETWORKING




CREATE A CONNECTION/NETWORK BETWEEN 2 OR MORE BOARDS WITH WIRE OR WIRELESS




For this assignment we had to connect at least 2 boards and let them communicate. Since in my final project I will add some ultrasonic sensor, I tried to create a connection between 2 ultrasonic sensors boards ( one bridge and one slave ). Since I am currently attending the Global Summer School by Iaac (visiting Moscow), I am producing these boards in Shukhov Lab, a brand new fablab with good equipment, great instructors and full of events and important activities. Anyway, I have uploaded my input board adding an extra bus, with Tx, Rx, Vcc, Gnd pins. I have decided to keep for each board the ftdi pins also for the slave, in order to use them in different ways for my final project.







For the production of the boards Ivan Mitrofanov (former fabacademy student), gave me a huge support for this assignment about producing the board and suggesting me where to buy components. I am very thankful to him.
The equipment we used is showed to the next picture. I have used fabmodules exporting the files it in .svg.






DOWNLOAD FILES


EagleFile.brd EagleFile.sch




Here some pictures of the boards after milling and cutting and some components I have bought in Russia. The shop, which is actually well provided, is ChipDip.









After that, with Arduino IDE I compiled this sketch

#include <SoftwareSerial.h>

#define TxPin 1
#define RxPin 0
#define nodeId 'a'
#define echoPin 9 //PB1
#define triggerPin 10 //PB0
int distance;

void setup()
{
  pinMode(triggerPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(TxPin, INPUT);
}


void loop()
{
  char c = Serial.read();


  if (c==nodeId)
  {
    distance = measureDistance();
    pinMode(TxPin, OUTPUT);
    Serial.print("Sensor: ");
    Serial.print(nodeId);
    Serial.print("Distance:");
    Serial.println(distance);
    pinMode(TxPin, INPUT);
  }
}

int measureDistance()
{
  digitalWrite(triggerPin, LOW);
  delayMicroseconds(2);

  digitalWrite(triggerPin, HIGH);
  delayMicroseconds(10);

  digitalWrite(triggerPin, LOW);


  distance = pulseIn(echoPin, HIGH)/58;

  return distance;
}


Let's attach the boards, load the sketch and see what happens through the serial port.