Raspberry pi Zero launched , SBC priced at $5

This is awesome. The only thing I miss is the LAN interface but at $5 its still amazing. It has Broadcom BCM2835 processor and that also 40% faster than the pi 1 with 512 MB of Ram.

Today, I’m pleased to be able to announce the immediate availability of Raspberry Pi Zero, made in Wales and priced at just $5. Zero is a full-fledged member of the Raspberry Pi family, featuring:

  • A Broadcom BCM2835 application processor
    • 1GHz ARM11 core (40% faster than Raspberry Pi 1)
  • 512MB of LPDDR2 SDRAM
  • A micro-SD card slot
  • A mini-HDMI socket for 1080p60 video output
  • Micro-USB sockets for data and power
  • An unpopulated 40-pin GPIO header
    • Identical pinout to Model A+/B+/2B
  • An unpopulated composite video header
  • Our smallest ever form factor, at 65mm x 30mm x 5mm

Raspberry Pi Zero runs Raspbian and all your favourite applications, including Scratch, Minecraft and Sonic Pi.

RaspberryPi BLOG

 

easyavr.h Header file for pin/port operations

Here I am sharing a header file called easyavr.h. This is a pretty basic header file with some helper functions related to input output pins of AVR

#ifndef __EASYAVR_H_
#define __EASYAVR_H_


//  Sets pin of port to 1
//
//  Example for PD2: PIN_ON(PORTD, 2)
#define PIN_ON(port,pin) ((port) |= (1 << (pin)))


//  Sets pin of port to 0
//
//  Example for PD2: PIN_OFF(PORTD, 2)
#define PIN_OFF(port,pin) ((port) &= ~(1 << (pin)))


//  Sets pin of port to value
//
//  Example for PD2: PIN_SET(PORTD, 2, 1)
#define PIN_SET(port,pin,val) (((val) > 0) ? PIN_ON((port),(pin)) : PIN_OFF((port),(pin)))

//  Sets all of port pins to OUTPUT mode
//
//  Example for PORTD: PORT_AS_OUTPUT(PORTD)
#define PORT_AS_OUTPUT(port) ((port) = 0xFF)

//  Sets all of port pins to INPUT mode
//
//  Example for PORTD: PORT_AS_INPUT(PORTD)
#define PORT_AS_INPUT(port) ((port) = 0x00)

//  Sets pin of port to OUTPUT mode
//
//  Example for PD1: PORT_AS_OUTPUT(DDRD, 1)
#define PIN_AS_OUTPUT(ddr,pin) ((ddr) |= (1 << (pin)))


//  Sets pin of port to INPUT mode
//
//  Example for PD1: PORT_AS_INPUT(DDRD, 1)
#define PIN_AS_INPUT(ddr,pin) ((ddr) &= ~(1 << (pin)))

//  Checks pin's value of port
//  Returns 1 or 0
//
//  Example for PD2: CHECK_PIN(PIND, 2)
#define CHECK_PIN(pinreg,pin) (((pinreg) & (1 << (pin))) != 0)


#endif
 

Chocometer :an open source near infrared sensor aiming glucose measurements without pain.

marcelclaro’s project for The Hackaday Prize aims to do just that. Instead of measuring blood directly, his project will measure blood glucose by shining light through a finger or an earlobe. Using light to detect blood glucose is something that has been studied in the lab, but so far, there aren’t any products on the market that use this technique.

There are two major problems marcel needs to overcome to turn this project into reality. The first is simply raw data for calibration. For [marcel], this is easy; he has Type 1 diabetes, and takes four glucose measurements a day. Patient heal thyself, or something.

The second problem is getting a photosensor that’s sensitive enough. By using an InGaAs PIN diode, a current-controlled oscillator, and a digital counter, [marcel] should have a sensor that’s good enough, with electronics that are cheap enough, to create some tech that is truly game changing for a few hundred million people around the world.

 

LPC810 Breakout Board

This basic Arm Cortex-M0+ NXP LPC810 breakout board features a FTDI programming header, USB (mini-B) connector for power only, a LM117-3.3v voltage regulator, power LED, ISP and Reset buttons and a standard 2×5-pin 0.05″ SWD debug connector. All pins are brought out to the edge of the board. Three PCBs from OSHPark.com cost me $6.55 […]

https://ucexperiment.wordpress.com/2015/02/22/lpc810-breakout-board/

 

Analog pH Meter with PIC16F684 and arduino

Need to measure water quality and other parameters?  DF Robot’s Analog pH Meter Kit is  specially designed for simple interface and has convenient and practical connector and a bunch of features. Get pH measurements at ± 0.1pH (25 ℃). For most hobbyist this great accuracy range and it’s low cost makes this a great tool for biorobotics and other projects! It has an LED which works as the Power Indicator, a BNC connector and PH2.0 sensor interface. To use it, just connect the pH sensor with BND connector, and plug the PH2.0 interface into the analog input port of any micro-controller.

The Wiki page  has a sample code for using this kit with arduino,  along with schematic, specifications, features ,precautions and setup Instructions. The arduino Interfacing is simple and the schematic and code is available on the wiki page.

PH_meter_connection1_(1)

Interfacing with a pic is also straight forward, Shawon Shahryiar shared his project where he used a PIC16F684. Below is the demonstration video and code.

/*
Coder: Shawon Shahryiar
https://www.facebook.com/groups/ArduinoBangla/
https://www.facebook.com/groups/microarena/
https://www.facebook.com/MicroArena
 */


#include <16F684.h>

#device *= 16
#device ADC = 10

#fuses NOWDT, INTRC_IO, PROTECT, PUT, CPD
#fuses NOBROWNOUT, NOMCLR, NOIESO, FCMEN

#use delay (internal = 4MHz)


#include "lcd.c"


#define const_A 0.00171016
#define LED	pin_C3


const unsigned char symbol[16] ={
    0x00, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00, 0x00,
    0x00, 0x00, 0x0E, 0x0E, 0x0E, 0x00, 0x00, 0x00
};


void setup();
void lcd_symbol();
unsigned long adc_avg();
void show_bar(unsigned char value);

void main() {
    unsigned char samples_A = 0x00;
    unsigned char samples_B = 0x00;
    unsigned long temp = 0x0000;
    unsigned long avg = 0x0000;
    unsigned long buffer[10];
    float pH_value = 0.0;

    memset(buffer, 0x00, sizeof (buffer));

    setup();

    while (TRUE) {
        for (samples_A = 0; samples_A < 10; samples_A++) {
            buffer[samples_A] = adc_avg();
            delay_ms(9);
        }

        for (samples_A = 0; samples_A < 9; samples_A++) {
            for (samples_B = (1 + samples_A); samples_B < 10; samples_B++) {
                if (buffer[samples_A] > buffer[samples_B]) {
                    temp = buffer[samples_A];
                    buffer[samples_A] = buffer[samples_B];
                    buffer[samples_B] = temp;
                }
            }
        }

        avg = 0;

        for (samples_A = 3; samples_A < = 6; samples_A++) {
            avg += buffer[samples_A];
        }

        avg >>= 2;

        pH_value = (avg * const_A);

        lcd_gotoxy(1, 1);
        printf(lcd_putc, "pH Value: %2.2g ", pH_value);
        show_bar(((unsigned char) pH_value));
    };
}

void setup() {
    disable_interrupts(GLOBAL);
    setup_WDT(WDT_off);
    setup_oscillator(OSC_4MHz);
    setup_comparator(NC_NC_NC_NC);
    setup_ADC(ADC_clock_div_8);
    setup_ADC_ports(sAN0);
    set_ADC_channel(0);
    setup_CCP1(CCP_off);
    setup_timer_0(T0_internal);
    setup_timer_1(T1_disabled);
    setup_timer_2(T2_disabled, 255, 1);
    set_timer0(0x00);
    set_timer1(0x0000);
    set_timer2(0x00);
    lcd_init();
    lcd_symbol();
    delay_ms(4000);
}

void lcd_symbol() {
    unsigned char s = 0;

    lcd_send_byte(0, 0x40);

    for (s = 0x00; s < = 0x0F; s++) {
        lcd_send_byte(1, symbol[s]);
    }

    lcd_send_byte(0, 0x80);
}

unsigned long adc_avg() {
    unsigned char samples = 4;
    unsigned long avg = 0;

    while (samples > 0) {
        read_adc(adc_start_only);
        while (!adc_done());
        avg += read_adc(adc_read_only);
        samples--;
    }
    avg /= 4.0;

    return avg;
}

void show_bar(unsigned char value) {
    unsigned char x_pos = 0;

    for (x_pos = 1; x_pos < = 16; x_pos++) {
        lcd_gotoxy(x_pos, 2);
        lcd_putc(0);
    }

    lcd_gotoxy((value + 1), 2);
    lcd_putc(1);

    output_toggle(LED);
    delay_ms(100);
} 
 

Solar Charge Controller Improves Efficiency of Solar Panels

The simplest and easiest way to charge a battery with a solar panel is to connect the panel directly to the battery. Assuming the panel has a diode to prevent energy from flowing through it from the battery when there’s no sunlight. This is fairly common but not very efficient. [Debasish Dutta] has built a charge controller that addresses the inefficiencies of such a system though, and was able to implement maximum power point tracking using an Arduino.

Maximum power point tracking (MPPT) is a method that uses PWM and a special DC-DC converter to match the impedance of the solar panel to the battery. This means that more energy can be harvested from the panel than would otherwise be available. The circuit is placed in between the panel and the battery and regulates the output voltage of the panel so it matches the voltage on the battery more closely. [Debasish] reports that an efficiency gain of 30-40% can be made with this particular design.

This device has a few bells and whistles as well, including the ability to log data over WiFi, an LCD display to report the status of the panel, battery, and controller, and can charge USB devices. This would be a great addition to any solar installation, especially if you’ve built one into your truck.

via Hackaday

 

Measuring Heart Rate With A Piezo

Look around for heart rate sensors that interface easily to microcontrollers, and you’ll come up with a few projects that use LEDs and other microcontrollers to do the dirty work of filtering out pulses in a wash of light.

[Thomas] was working on a project that detects if water is flowing through a pipe with a few piezoelectric sensors. Out of curiosity, he taped the sensor to his finger, and to everyone’s surprise, the values his microcontroller were spitting out were an extremely noise-free version of his heart rate.

The piezo in question is a standard, off the shelf module, and adding this to a microcontroller is as easy as putting the piezo on an analog pin. From there, it’s just averaging measurements and extracting a heartbeat from the data.

Via hackaday.com

 

Pic based temperature sensor with 7 segment display and ds18b20

This circuit is a Digital Temerature Sensor using a Dallas ‘1-wire’ DS18B20 Digital Thermometer


Firstly I would like to thank Pommie and Mike, K8LH from the Electro Tech Online Forum for their genourous help. This has been the most challenging project to date and they have helped immensely. They have tought me many valuable lessons about programming in Assembly language and it has really assitsted me in getting this project up and running.

Note: I would like to make a point that some snippets of their own code is used in this program. I have used it with their permission and please observe any copyrights or name recognition placed in the code. If you wish to use their snippets of code, please contact them via the Electro-Tech-Online forum.

How It Works

The DS18B20 is a direct-to-digital temperature sensor using Maxim’s exclusive 1-Wire bus protocol that implements bus communication using one control signal. In regards to hardware, this particular sensor is particularly easy to interface to. It only requires 1 external pull-up resistor to operate as opposed to an analogue sensor which possibly needs multiple external components such as resistors and op-amps.

In regards to software, opposed to analogue sensors, the Dallas 1-wire digital sensors are arguably as easy to interface to. While an analogue sensor will need an Analogue to Digital conversion using a voltage reference and possibly using an op-amp, the Dallas 1-wire direct to digital sensors require precise timing when it comes to communication. This program is fairly basic in principle as all it does is obtain temperature data from the DS18B20 sensor and display the temperature in Degrees Celsius on a 4 digit, 7 segment display. But when it comes to actually doing this, as you will see from the .ASM file, it is more complicated than it sounds. In words; the program first initialises the PIC16F628A Microcontroller. It assigns the Inputs and Outputs, zero’s all bank 0 RAM, initialises the display column select bit and configures TIMER 2. TIMER 2 is used to interrupt the normal loop of the program to update the 7 segment LED display.

After the Microcontroller has been setup, it begins communication with the DS18B20 Temperature Sensor. Communication routines take up just under half of the program memory. After the temperature has been gathered and stored in RAM, the Microcontroller takes the 12-bit signed/fraction integer and converts it into a decimal number then stores it in four general purpose registers in RAM.

For example, take the number D’95.8′. It is stored like this:

HUNS register = 0
TENS register = 9
ONES register = 5
TENTHS register = 8

These registers are then used within the Interrupt Service Routine to call a table to obtain display data.
The program runs continuously, updating the temperature on the display just over once per 1 second.

Features Summary:

  • Temperature data gathered more than once per second.
  • TIMER 2 interrupt driven display.
  • Program expandable to include multiple sensors on the same 1-Wire bus.
  • Temperature range of -55.0 – 127.9 Degrees Celsius.

Please see the DS18B20 Datasheet for detailed information on the device.

schematicbreadboard

 

 

digitaltemperaturesensorbasic.zip

Here is the complete project   (with explanation , code, schematic and video)

 

upload/downlaod file from FTP using AT commands (Sim900 + arduino)

In the previous post I explained how to make a connection and send data via TCP connection on SIM900 and similar modems. This post is going to be about FTP connection. FTP stands for “file transfer protocol.” FTP powers one of the fundamental Internet functions and is the prescribed method for the transfer of files between computers. It is also the easiest and most secure way to exchange files over the Internet.

Without going into much details I would show the related AT commands and brief description. Later I would include sample code for FTP upload/download using arduino and SIM900

AT command Response Description
AT+SAPBR OK Configures GPRS profile.
AT+FTPCID=1 OK Selects profile 1 for FTP.
AT+FTPSERV=”****” OK Sets FTP server domain name or IP address. **** is the domain name or the IP.
AT+FTPPORT=*** OK Sets FTP server port. *** is the port.
AT+FTPUN=”***” OK Sets user name for FTP server access. *** is the user name.
AT+FTPPW=”***” OK Sets password for FTP server access. *** is the password.
AT+FTPPUTNAME=”****” OK Sets destiny name for the file.*** is the name of the file.
AT+FTPPUTPATH=”****” OK Sets destiny file path. *** is the path of the file.
AT+FTPPUT OK Use to put a file into the FTP server.
AT+FTPGETNAME=”****” OK Sets origin name for the file.*** is the name of the file.
AT+FTPGETPATH=”****” OK Sets origin file path. *** is the path of the file.
AT+FTPGET Use to get a file into the FTP server.

Make sure you have a server and note the ftp port, we would consider using the default port 21. Switch on your modem and make sure pin code is disabled or properly entered and that GPRS connection is available.

  1. Configure GPRS by sending AT+SAPBR=3,1,”Contype”,”GPRS”r  .
  2. Set APN by sending   AT+SAPBR=3,1,”APN”,”your apn”r  .replace your apn with APN for your network.
  3. Now set the username and password for the apn (replace username and password with correct values )
    AT+SAPBR=3,1,”USER”,”username”r  .
    AT+SAPBR=3,1,”PASS”,”password”r
  4. Connect to GPRS connection by sending AT+SAPBR=1,1r, when connected Modem will respond with OK
  5. Now select profile 1 for FTP by sending AT+FTPCID=1r
  6. Now set FTP server domain or ip using the command AT+FTPSERV=ftp.yourserver.comr
  7. Set FTP port by AT+FTPPORT=21r
  8. Now send FTP credentials using AT+FTPUN=user_namer and AT+FTPPW=”password”r
  9. To get a file from FTP send AT+FTPGETNAME=file_namer
  10.  Now set the path of the file AT+FTPGETPATH=/path/r
  11. Now send AT+FTPGET=1r and wait for response from server, which starts with +FTPGET:1,1
  12. To upload a file to FTP server send AT+FTPPUTNAME=file_namer
  13. Now set path AT+FTPPUTPATH=/pathr
  14. Now send AT+FTPPUT=1 and wait for +FTPPUT:1,1 after which you need to send the content of file to be uploaded.

int8_t answer;
int onModulePin = 2;
char aux_str[30];

char incoming_data[120];

char test_str[ ]= "0000000011111111222222223333333344444444555555556666666677777777000000001111111122222222333333334444";

int data_size, aux;


void setup(){

    pinMode(onModulePin, OUTPUT);
    Serial.begin(115200);


    Serial.println("Starting...");
    power_on();

    delay(5000);

    Serial.println("Connecting to the network...");

    while( (sendATcommand("AT+CREG?", "+CREG: 0,1", 500)
            || sendATcommand("AT+CREG?", "+CREG: 0,5", 500)) == 0 );

    configure_FTP();

    uploadFTP();

    downloadFTP();

    Serial.print("Incoming data: ");
    Serial.println(incoming_data);
}


void loop(){

}


void configure_FTP(){

    sendATcommand("AT+SAPBR=3,1,"Contype","GPRS"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"APN","APN"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"USER","user_name"", "OK", 2000);
    sendATcommand("AT+SAPBR=3,1,"PWD","password"", "OK", 2000);

    while (sendATcommand("AT+SAPBR=1,1", "OK", 20000) != 1);
    sendATcommand("AT+FTPCID=1", "OK", 2000);
    sendATcommand("AT+FTPSERV="ftp.yourserver.com"", "OK", 2000);
    sendATcommand("AT+FTPPORT=21", "OK", 2000);
    sendATcommand("AT+FTPUN="user_name"", "OK", 2000);
    sendATcommand("AT+FTPPW="password"", "OK", 2000);

}


void uploadFTP(){

    sendATcommand("AT+FTPPUTNAME="file_name"", "OK", 2000);
    sendATcommand("AT+FTPPUTPATH="/path"", "OK", 2000);
    if (sendATcommand("AT+FTPPUT=1", "+FTPPUT:1,1,", 30000) == 1)
    {
        data_size = 0;
        while(Serial.available()==0);
        aux = Serial.read();
        do{
            data_size *= 10;
            data_size += (aux-0x30);
            while(Serial.available()==0);
            aux = Serial.read();
        }
        while(aux != 0x0D);

        if (data_size >= 100)
        {
            if (sendATcommand("AT+FTPPUT=2,100", "+FTPPUT:2,100", 30000) == 1)
            {
                Serial.println(sendATcommand(test_str, "+FTPPUT:1,1", 30000), DEC);
                Serial.println(sendATcommand("AT+FTPPUT=2,0", "+FTPPUT:1,0", 30000), DEC);
                Serial.println("Upload done!!");
            }
            else
            {
                sendATcommand("AT+FTPPUT=2,0", "OK", 30000);
            }
        }
        else
        {
            sendATcommand("AT+FTPPUT=2,0", "OK", 30000);
        }
    }
    else
    {
        Serial.println("Error openning the FTP session");
    }
}

void downloadFTP(){

    int x = 0;

    sendATcommand("AT+FTPGETNAME="file_name"", "OK", 2000);
    sendATcommand("AT+FTPGETPATH="/path"", "OK", 2000);
    if (sendATcommand("AT+FTPGET=1 ", "+FTPGET:1,1", 30000) == 1)
    {
        do{
            if (sendATcommand2("AT+FTPGET=2,50", "+FTPGET:2,", "+FTPGET:1,", 30000) == 1)
            {
                data_size = 0;
                while(Serial.available()==0);
                aux = Serial.read();
                do{
                    data_size *= 10;
                    data_size += (aux-0x30);
                    while(Serial.available()==0);
                    aux = Serial.read();
                }while(aux != 0x0D);

                Serial.print("Data received: ");
                Serial.println(data_size);

                if (data_size > 0)
                {
                    while(Serial.available() < data_size);
                    Serial.read();

                    for (int y = 0; y < data_size; y++)
                    {
                        incoming_data[x] = Serial.read();
                        x++;
                    }
                    incoming_data[x] = '';
                }
                else
                {
                    Serial.println("Download finished");
                }
            }
            else if (answer == 2)
            {
                Serial.println("Error from FTP");
            }
            else
            {
                Serial.println("Error getting the file");
                data_size = 0;
            }
        }while (data_size > 0);
    }
    else
    {
        Serial.println("Error openning the FTP session");
    }
}




void power_on(){

    uint8_t answer=0;

    // checks if the module is started
    answer = sendATcommand("AT", "OK", 2000);
    if (answer == 0)
    {
        digitalWrite(onModulePin,HIGH);
        delay(3000);
        digitalWrite(onModulePin,LOW);

        while(answer == 0){     // Send AT every two seconds and wait for the answer
            answer = sendATcommand("AT", "OK", 2000);
        }
    }
}


int8_t sendATcommand(char* ATcommand, char* expected_answer, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '', 100);    // Initialize the string

    delay(100);

    while( Serial.available() > 0) Serial.read();    // Clean the input buffer

    Serial.println(ATcommand);    // Send the AT command


        x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        if(Serial.available() != 0){
            // if there are data in the UART input buffer, reads it and checks for the asnwer
            response[x] = Serial.read();
            //Serial.print(response[x]);
            x++;
            // check if the desired answer  is in the response of the module
            if (strstr(response, expected_answer) != NULL)
            {
                answer = 1;
            }
        }
    }
    // Waits for the asnwer with time out
    while((answer == 0) && ((millis() - previous) < timeout));

        return answer;
}

int8_t sendATcommand2(char* ATcommand, char* expected_answer1,
            char* expected_answer2, unsigned int timeout){

    uint8_t x=0,  answer=0;
    char response[100];
    unsigned long previous;

    memset(response, '', 100);    // Initialize the string

    delay(100);

    while( Serial.available() > 0) Serial.read();    // Clean the input buffer

    Serial.println(ATcommand);    // Send the AT command


        x = 0;
    previous = millis();

    // this loop waits for the answer
    do{
        // if there are data in the UART input buffer, reads it and checks for the asnwer
        if(Serial.available() != 0){
            response[x] = Serial.read();
            x++;
            // check if the desired answer 1 is in the response of the module
            if (strstr(response, expected_answer1) != NULL)
            {
                answer = 1;
            }
            // check if the desired answer 2 is in the response of the module
            if (strstr(response, expected_answer2) != NULL)
            {
                answer = 2;
            }
        }
        // Waits for the asnwer with time out
    }while((answer == 0) && ((millis() - previous) < timeout));

        return answer;
}