Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. ahmedadelhosni
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    ahmedadelhosni

    @ahmedadelhosni

    36
    Reputation
    325
    Posts
    1554
    Profile views
    0
    Followers
    6
    Following
    Joined Last Online
    Website ahmedadel90.wordpress.com Location Egypt, Cairo Age 32

    ahmedadelhosni Follow
    Hardware Contributor

    Best posts made by ahmedadelhosni

    • [Tutorial] How to burn 1Mhz & 8Mhz bootloader using Arduino IDE 1.6.5-r5

      Hello everyone,

      Last week I received my slim node board designed by m26872 and begun the process of burning the 1Mhz bootloader. I faced some problems for a couple of hours and google helped me to successfully burn it and uploading the sketch.
      Please correct me if I missed something. I tried to re-do the steps now before writing the post to make sure it works.

      I am using Arduino IDE 1.6.5-r5 with Arduino UNO board.
      I used some photos from arduino.cc
      I will explain flashing both 8Mhz and 1Mhz configurations.

      1- You will need the following

      • Arduino UNO ( didn't test using other boards)
      • Atmega328p chip ( with preloaded bootloader or without )
      • Breadboard
      • Wires
      • Crystal ( optional )

      2-

      • Connect your arduino UNO to your laptop.
      • Open Arduino IDE.
      • Go to File > Examples > Arduino ISP

      0_1454446970268_1.png

      • Go to Tools and make sure you choose Arduino/Genuino Uno and you COM port.
        Your COM port may be different than mine

      0_1454447281880_2.png

      Note: The following step solved my problem when I failed to upload the bootloader at the beginning.

      • Go to Tools > Programmer > Arduino as ISP

      Make sure to choose "Arduino as ISP" not "ArduinoISP"

      0_1454447412898_3.png

      Then upload your ArduinoISP sketch.

      • It will take less than a minute.
      • Close the sketch ArduinoISP adter uploading successfully.

      *********************************** . ***********************************
      *********************** Burning the bootloader ***********************
      *********************************** . ***********************************

      3- For burning the bootloader you have to set your environment as shown in the figure below:
      Remove the arduino usb cable and begin wiring.

      0_1454446598443_4.png

      Double check your wires and make sure they are connected in the correct pin.

      *********************************** . ***********************************
      ********************** Burning 8Mhz bootloader **********************
      *********************************** . ***********************************

      Quoted from Arduino.cc :

      • Download this hardware configuration archive: breadboard-1-6-x.zip
      • Extract the zip file. A folder with name "breadboard" will appear.
      • Open your Arduino folder path and move the breadboard folder from the zip archive to the "hardware" folder of your Arduino sketchbook.
      • Restart the Arduino software.
        You should see "ATmega328 on a breadboard (8 MHz internal clock)" in the Tools > Board menu.
      • Be sure to select "ATmega328 on a breadboard (8 MHz internal clock)" when burning the bootloader.(If you select the wrong item and configure the microcontroller to use an external clock, it won't work unless you connect one.)
      • Once you've done this, you can burn the bootloader and upload programs onto your ATmega328p. To burn the bootloader go to Tools > Burn bootloader

      0_1454448243570_5.png

      It will take less than a minute and leds will flash. Wait until bootloader is burned.

      0_1454448363854_6.png

      *********************************** . ***********************************
      ********************** Burning 1Mhz bootloader **********************
      *********************************** . ***********************************

      • I followed m26872 guides in his project My Slim 2AA Battery Node to get the 1Mhz bootloader. I'll copy some of his instructions.

      • I use this precompiled bootloader from here. It's an Optiboot with 1MHz internal clock and 9600 baud serial communication. Fuse changed to BOD disable.

      • Rename your .hex to atmega328_1a.hex

      • Move it to "ARDUINO_PATH" > hardware > arduino > avr > bootloaders

      0_1454448897446_8.png

      • We need to add the new board to the boards.txt file located at "ARDUINO_PATH" > hardware > arduino > avr
      • Open boards.txt
      • Go to this link.
      • Copy the content of the link and paste it at the end of boards.txt

      0_1454449112046_9.png

      • Restart you Arduino IDE.
      • You should see "APM Optiboot internal 1Mhz noBOD 9600baud" in the Tools > Board menu.
      • Once you've done this, you can burn the bootloader and upload programs onto your ATmega328p. To burn the bootloader go to Tools > Burn bootloader

      0_1454451123401_10.png

      Tips about burning the bootloader if it failed:

      1- I faced the following issues and was solved as follows:

      avrdude: Yikes! Invalid device signature.
      Double check connections and try again, or use -F to override

      • Maybe your chip is configured to run on an external crystal clock. I tested with two values and it succeeded. I used 10Mhz and 20Mhz as I didn't have 16 Mhz.
      • Connect the crystal to pin 9 and 10
      • Note: You won't need the crystal except for the first time as the new bootloader is configured to run on internal 1Mhz or 8Mhz.

      2-

      avrdude: Error: Could not find USBtiny device (0x2341/0x49)

      Make sure you chose "Arduino as ISP" not "ArduinoISP" from the programmer list. You will find it in Tools menu.

      3-

      avrdude: can't open input file D:\arduino-1.6.5-r5\hardware\arduino\avr/bootloaders/atmega328_1a.hex: No such file or directory
      avrdude: read from file 'D:\arduino-1.6.5-r5\hardware\arduino\avr/bootloaders/atmega328_1a.hex' failed
      Error while burning bootloader.

      Your .hex file is not in the correct path.

      • According to the .boards file, the path is configured to be in the default path arduino-1.6.5-r5\hardware\arduino\avr\bootloaders

      You can find this configuration in the boards.txt as follows:
      apm96.bootloader.file=atmega328_1a.hex

      If you wish to put the .hex file in a folder, so you will have to edit the path above in the boards.txt

      Example:You put the .hex file in > arduino-1.6.5-r5\hardware\arduino\avr\bootloaders\MyOneMhz
      So change the line to this: apm96.bootloader.file=MyOneMhz/atmega328_1a.hex

      *********************************** . ***********************************
      ********************** End of burning bootloader **********************
      *********************************** . ***********************************

      *********************************** . ***********************************
      ************************ Uploading the sketch *************************
      *********************************** . ***********************************

      4- Once your ATmega328p has the Arduino bootloader on it, you can upload programs to it using the USB-to-serial convertor (FTDI chip) on an Arduino board. To do so, you remove the microcontroller from the Arduino board so the FTDI chip can talk to the microcontroller on the breadboard instead.

      • Set the environment as follows:
        The picture at the bottom shows how to connect the RX and TX lines from the Arduino UNO board to the ATmega on the breadboard.

      0_1454449899848_7.png

      After finishing wiring and recheck connections:

      • Choose your desired board which we have added before and burned the atmega328p with it.
      • Upload your sketch normally.
      • Leds will flash in the Arduino UNO board.
      • Sketch will take some time with 1Mhz and it is faster with 8Mhz because of the baud rate chosen in 1Mhz.

      *********************************** . ***********************************
      *************************** ** References ** **************************
      *********************************** . ***********************************

      • How To Load Bootloader onto Arduino
      • Re: Burning bootloader on standalone Atmega328(internal clock 8MHz)
      • From Arduino to a Microcontroller on a Breadboard

      *********************************** . ***********************************
      *************************** ** THE END ** *****************************
      *********************************** . ***********************************

      I hope it was clear enough and doesn't contain mistakes. Please let me know if something was missing.
      I encourage you to add your tips and tricks so that we can learn.

      Thanks.

      posted in Development
      ahmedadelhosni
      ahmedadelhosni
    • RE: Step-by-step procedure to connect the NRF24L01+ to the GPIO pins and use the Raspberry as a Serial Gateway (MySensors 1.x)

      Great and simple.
      Is connecting the nrf directly to the pi causes any problems and u need to restart it ?
      Thanks.

      posted in Hardware
      ahmedadelhosni
      ahmedadelhosni
    • RE: LDO 9 volt

      I was thinking about ordering MCP1702. It has 2us quiescent current.

      posted in Hardware
      ahmedadelhosni
      ahmedadelhosni
    • RE: GatewayESP8266MQTTClient in Development Branch

      Hello,

      This reply is related to another topic http://forum.mysensors.org/topic/2378/how-can-i-set-the-payload-for-mqtt-v1-6 where I wasn't able to send my buffer from my mqtt gateway to another sensor node. After spending all day today debugging the issue, I was able to find two bugs and to send the buffer correctly.

      This is the topic which I subscribe to

      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygatewayin"
      

      This is how I send my mqtt pattern using MQTTlens or Mosquitto to be published to the gateway. My message contains 1 or 0 to turn ON or OFF a relay in my sensor node with id 4, child id 19, set, no ack, V_LIGHT

      mygatewayin/4/19/1/0/2
      

      The first problem which I faced is that my mqtt buffer wasn't evaluated in the callback function incomingMQTT() found in MyGatewayTransportMQTTClient.cpp

      After checking the case switch I found out that the rest of the case switches doesn't continue because the code returns due to the following line

      if (strcmp_P(str, MY_MQTT_SUBSCRIBE_TOPIC_PREFIX) != 0)
      {
          return;
      }
      

      According to http://www.nongnu.org/avr-libc/user-manual/group__avr__pgmspace.html#gad34d5b7d040fcb97939e939f19d88a5f

      The strcmp_PF() function returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2. The contents of RAMPZ SFR are undefined when the function returns

      Actually I haven't used this function before but according to description it will return 0 if they are identical, so using != shall be right, but actually it was solved when I replaced it with == instead of !=

      Finally I was able to evaluate the buffer and the case switches continued.

      But Also this didn't solve the problem and the buffer wasn't sent to the sensor node id 4

      After lots of printing functions for debugging I found that in serial monitoring, the following is printed

      send: 0-0-0-4 s=19,c=1,t=2,pt=0,l=1,sg=0,st=fail:1
      

      While when I use Serial gateway which is working well till now, the following is printed instead

      send: 0-0-4-4 s=19,c=1,t=2,pt=0,l=1,sg=0,st=ok:1
      

      Thus I found that the difference is in 0-0-X-4.

      Searching further in the code, I found that the debug function for this line is used in MyTransport.cpp in function transportSendWrite(uint8_t to, MyMessage &message)

      debug(PSTR("send: %d-%d-%d-%d s=%d,c=%d,t=%d,pt=%d,l=%d,sg=%d,st=%s:%s\n"),
      			message.sender,message.last, to, message.destination, message.sensor, mGetCommand(message), message.type,
      			mGetPayloadType(message), mGetLength(message), mGetSigned(message), to==BROADCAST_ADDRESS ? "bc" : (ok ? "ok":"fail"), message.getString(_convBuf));
      

      So the difference here is that the variable to is set as 0 in case of mqttgateway, while it is set as 4 correctly using Serial gateway.

      So finally this is what I have reached.

      In MyTransport.cpp in function boolean transportSendRoute(MyMessage &message)

      #if !defined(MY_REPEATER_FEATURE)
          // None repeating node... We can only send to our parent\\
          ok = transportSendWrite(_nc.parentNodeId, message);
      #endif
      

      The above is called because MY_REPEATER_FEATURE is not defined, thus the mqttgateway sends always 0 instead of the required node id.

      I tried to define MY_REPEATER_FEATURE but I found big memory size and the software was crazy.
      Also in MySensor.h it is not mentioned to be defined

      #if defined(MY_GATEWAY_MQTT_CLIENT)
      ... some code ...
      ... some code ...
      #elif defined(MY_GATEWAY_FEATURE)
      ... some code ...
      	#if defined(MY_RADIO_FEATURE)
      		// We assume that a gateway having a radio also should act as repeater
      		#define MY_REPEATER_FEATURE
      	#endif
      

      What I did now as a workaround because it is 2:40 AM here and I need to sleep 😄 Is the following

      In MyTransport.cpp

      	#if !defined(MY_REPEATER_FEATURE)
      		#if defined(MY_GATEWAY_MQTT_CLIENT)
      			ok = transportSendWrite(message.destination, message);
      		#else
      		// None repeating node... We can only send to our parent
      		ok = transportSendWrite(_nc.parentNodeId, message);
      		#endif
      	#else
      

      Please check whether this will solve the problem or not. Please correct me if I was wrong. It's my first time to look around in the library today.

      Thanks.

      posted in Development
      ahmedadelhosni
      ahmedadelhosni
    • RE: My Slim 2AA Battery Node

      First node. Door sensor.
      Great boards :+
      0_1453937636107_1453937611984-964477924.jpg

      0_1453938444465_1453938399889-988876899.jpg

      .

      posted in My Project
      ahmedadelhosni
      ahmedadelhosni
    • RE: Are Chinese power supply chargers that dangerous to use ?

      @icebob After I have read almost most of the replies in the thread "safe in wall ... " I would tell you don't ever use this. This is even worse that charger number 1 and 2 which I posted above.

      After reading about safe circuits. The idea is that you need to protect all your component from damage and to avoid any overheating + you want a clean steady output.

      What i see now that there is no fuse nor varistor components at the AC input. The circuit uses only one diode for rectifying - the one at the upper right - not too bad but I read that a full wave rectifier with four diodes gives cleaner output. Other good circuits have an IC to control the output with feedback and has inbuilt over voltage / over current / over thermal protection. This one uses only transistor with - I guess - the other transistor for feedback. Another bad thing is that there is no isolation at all between high side voltage and low side voltage. The optocoupler in the middle should handle this in a better circuit desing, plus, there is no Y capacitor for isolation. ( See charger number 3, you will find an empty space in the middle and a blue component which is the Y capacitor )

      Thus this is a really simple AC to DC charger but with less protection and probably won't provide you with stable voltage. I don't encourage you to use this. You can check the two threads in my origianl post. They use HLK which is a great circuit design as a step down converter.

      posted in Hardware
      ahmedadelhosni
      ahmedadelhosni
    • RE: [SOLVED] Gateway as a sensor node in v1.6

      Yeah you solved this issue now. That's exactly what I needed 🙂

      The second picture explains it all. I wasn't able to understand how will I have several GWs although you explained it above from the beginning, but I wasn't aware how to do it. I remembered now from your last picture that domoticz can support several hardware. Thus I can make another GW and add it to the hardware in Domoticz as you have explained in your last picture.

      Thanks a lot for your time. Now it is very clear 🙂

      posted in Development
      ahmedadelhosni
      ahmedadelhosni
    • PINE A64, First $15 64-Bit Single Board Super Computer

      Hello.

      Did anyone check this great board on Kickstarter ? https://www.kickstarter.com/projects/pine64/pine-a64-first-15-64-bit-single-board-super-comput/description

      It shall be more powerful than Raspberry Pi 2. It is clear from its name that it is 64 bit. It is 1.2 Ghz clock + 1 or 2 GB of Ram. There are many great other features like the powerful Video output.

      What I like the most is that they stated directly that it is compataible with OpenHab controller.

      What do you think ?

      I backed them today and shipping is next march. Not bad at all for me.

      posted in General Discussion
      ahmedadelhosni
      ahmedadelhosni
    • RE: My Slim 2AA Battery Node

      @meddie
      0_1454272780491_1453938474660-1453938399889-988876899.jpg

      The sensor is drawn by black rectangle. This is adhesive tape like this : http://2.imimg.com/data2/YX/UQ/MY-3910304/sale-bopp-clarity-adhesive-tape-250x250.jpg

      The other red rectangle on the door was old tape I didn't remove. Actually before getting my boards I used a bread board and a battery for testing, so I needed a tape for support and keeping it in place 🙂

      posted in My Project
      ahmedadelhosni
      ahmedadelhosni
    • RE: MYSBootloader 1.3 pre-release & MYSController 1.0.0beta

      @scalz great.
      This means that MYSBootloader can handle this problem and enter the bootloader mode even if the MCU freezes.

      @tekka you state that the current version can handle a freeze SW. Also if the new code is corrupted during programming by unverified CRC or whatever, it will also handle that problem and resets and wait for a new flashing order.
      Is this new in this version ? I am some how sure that MYSBootloader previously had a problem handling thoses types of failures, and that's why I was going to use DualOptiboot as I read before that it can handle those failures

      Sorry for lots of questions but I am trying to reorganise my info.

      posted in Development
      ahmedadelhosni
      ahmedadelhosni

    Latest posts made by ahmedadelhosni

    • RE: PIR started reporting motion every 20 minutes [SOLVED]

      @strixx actually a have a similar problem but my OpenHab sends random notifications maybe every 2 days that motion was detected but i didnt debug yet. Whatever .. do you power your PIR with 5v ? With 3.3v for sure this will happen.

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: ESP8266 WiFi gateway port for MySensors

      Is it normal to use GPIO15 ? Isn't it used for booting mode ?

      posted in Development
      ahmedadelhosni
      ahmedadelhosni
    • RE: Unknown battery drain

      @tbowmo are they alkaline or lithuim ?

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: Unknown battery drain

      Thanks all.

      Actually @tbowmo i was asking about bootloader because I have opened another thread reagrding a problem where my node stops working sometimes when i use 1 Mhz. So i was asking what would it be the problem ? And what booloader + power supply technique do people use.

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: Door Sensor hangs up after some time (bootloader issue)

      Any updates here please ?

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: Unknown battery drain

      @tbowmo Thanks for the info.

      So here I have two questions. How do you power your node/radio ? how much days did it survive till now ?

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: Unknown battery drain

      @tbowmo wow 2.5 years !! Which bootloader are you using for your sleeping node ? It is Sensebender or did you modify it ?

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • Door Sensor hangs up after some time (bootloader issue)

      Hello,

      I recently was testing different boatloaders for Door sensor. I use 2x AAA batteries for my test.

      First one which caused the problem was : APM Optiboot internal 1MHz noBOD 9600baud

      
      
      apm96.name=APM Optiboot internal 1MHz noBOD 9600baud
      
      apm96.upload.tool=avrdude
      apm96.upload.protocol=arduino
      apm96.upload.maximum_size=32256
      apm96.upload.speed=9600
      apm96.bootloader.tool=avrdude
      apm96.bootloader.low_fuses=0x62
      apm96.bootloader.high_fuses=0xde
      apm96.bootloader.extended_fuses=0x07
      apm96.bootloader.path=optiboot_v50
      apm96.bootloader.file=atmega328_1a.hex
      apm96.bootloader.unlock_bits=0x3F
      apm96.bootloader.lock_bits=0x2F
      apm96.build.mcu=atmega328p
      apm96.build.f_cpu=1000000L
      apm96.build.core=arduino
      apm96.build.variant=standard
      
      

      Then I changed to :- ATmega328 on a breadboard (8 MHz internal clock)

      atmega328bb.name=ATmega328 on a breadboard (8 MHz internal clock)
      
      atmega328bb.upload.protocol=arduino
      atmega328bb.upload.maximum_size=30720
      atmega328bb.upload.speed=57600
      
      atmega328bb.bootloader.low_fuses=0xE2
      atmega328bb.bootloader.high_fuses=0xDA
      atmega328bb.bootloader.extended_fuses=0x05
      
      atmega328bb.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
      atmega328bb.bootloader.unlock_bits=0x3F
      atmega328bb.bootloader.lock_bits=0x0F
      
      atmega328bb.build.mcu=atmega328p
      atmega328bb.build.f_cpu=8000000L
      atmega328bb.build.core=arduino:arduino
      atmega328bb.build.variant=arduino:standard
      
      
      atmega328bb.bootloader.tool=arduino:avrdude
      atmega328bb.upload.tool=arduino:avrdude
      

      The first one has BOD at 1.8, and I read here in the forum that Atmega328p behaves strange when set to this value, although I read also that lots of people sees this a good practice to increase node life time.

      Problem till now is solved when I used the second bootloader.

      My question is:

      • Did anyone face this issue ?
      • Which bootloader fuses do you use for sleeping nodes ? WDT disabled ? No BOD ? or do you enable them ?
      • What battery types do you use ?

      Please share your experience.

      Thanks.

      posted in Troubleshooting
      ahmedadelhosni
      ahmedadelhosni
    • RE: 💬 Multi-Sensor: Temp/Humidity/PIR/ Leak/Magnet/Light/Accel

      @neverdie how do you connect thr two Cr batteries ?

      Another question ? I read in another comments that you need 100-200 uF capacitor so that the radio can work since thr CR battery wont be strong enough. Did you add this ?

      posted in OpenHardware.io
      ahmedadelhosni
      ahmedadelhosni
    • RE: 3V battery for door sensor node.

      Good topic. I have been lazy since a month to ask the same question regarding best batteries do people use for battery powered nodes ?

      I have thought of using AAA batteries but I really do not know which categories do I go with. Lithuim or Alkaline ?

      If you check this link https://d2ei442zrkqy2u.cloudfront.net/wp-content/uploads/2016/03/MN2400_US_CT1.pdf

      You find that the Alkaline battery can operate till it reaches 1.0 v for more than 1200 service hours. So two in Series will give me 2v which are still above 1.9 for the atmega and nrf to run.

      But also if you check lithuim batteries.
      http://data.energizer.com/pdfs/l92.pdf

      It also operates for 1200 service hours at 1.4v before the battery dies quickly.

      My question. Why would I choose a more expensive option (which is Lithuim) although I can use the Alkaline which is much cheaper and may be half the price ? Will the performance is better with steady voltage using lithuim ?

      Thanks.

      posted in General Discussion
      ahmedadelhosni
      ahmedadelhosni